Lorem Ipsum Generator now supports multiple languages through gettext-based internationalization (i18n).
- English (en - default)
- Spanish (es)
- German (de)
- French (fr)
- Portuguese (Brazilian) (pt_BR)
- Italian (it)
- Russian (ru)
- Japanese (ja)
- Ukrainian (uk)
LANGUAGE=es ./target/debug/loremgenerator # Spanish
LANGUAGE=de ./target/debug/loremgenerator # German
LANGUAGE=fr ./target/debug/loremgenerator # French
LANGUAGE=pt_BR ./target/debug/loremgenerator # Portuguese (Brazilian)
LANGUAGE=it ./target/debug/loremgenerator # Italian
LANGUAGE=ru ./target/debug/loremgenerator # Russian
LANGUAGE=ja ./target/debug/loremgenerator # JapaneseA convenience script is provided to run the application with language selection:
./run_localized.shThe script will prompt you to select your preferred language.
-
Copy the translation template:
cp po/loremgenerator.pot po/<language_code>.po
-
Edit the header in the new
.pofile:- Set the
Languagefield (e.g.,fr,de,pt_BR) - Update translator information
- Set the proper
Plural-Formsfor your language
- Set the
-
Translate all
msgstrentries that currently have empty strings -
Build the application to compile the translation:
cargo build
-
Test your translation:
LANGUAGE=<language_code> ./target/debug/loremgenerator
When new translatable strings are added to the source code:
-
Run the update script:
./update_translations.sh
-
Edit the updated
.pofiles to translate any new or modified strings -
Rebuild the application:
cargo build
po/
├── README.md # Translation documentation
├── loremgenerator.pot # Translation template (all extractable strings)
├── es.po # Spanish translation
└── <lang>.po # Other language translations
After building, compiled translations are placed in:
target/debug/locale/<lang>/LC_MESSAGES/loremgenerator.mo
target/release/locale/<lang>/LC_MESSAGES/loremgenerator.mo
The msgfmt tool from gettext is required to compile translations:
- Ubuntu/Debian:
sudo apt install gettext - Fedora:
sudo dnf install gettext - Arch Linux:
sudo pacman -S gettext - macOS:
brew install gettext
The application uses the system's gettext library, which is typically pre-installed on Linux systems.
In Rust code, wrap user-facing strings with the tr! macro:
// Instead of:
set_label: "Generate"
// Use:
set_label: &tr!("Generate")For strings used outside the macro context:
use gettextrs::gettext;
let translated = gettext("My translatable string");The update_translations.sh script uses xgettext to extract strings marked with:
tr!macrogettext()function
To verify translations are working:
- Build the project:
cargo build - Check compiled translations:
ls target/debug/locale/*/LC_MESSAGES/ - Run with specific language:
LANGUAGE=es ./target/debug/loremgenerator
All user-facing strings have been translated to Spanish:
| English | Spanish |
|---|---|
| _About | _Acerca de |
| Max Words | Máximo de Palabras |
| Max Sentences | Máximo de Oraciones |
| Paragraphs | Párrafos |
| Start with 'Lorem ipsum' | Comenzar con 'Lorem ipsum' |
| _Generate | _Generar |
| _Copy to Clipboard | _Copiar al Portapapeles |
| Copied to clipboard | Copiado al portapapeles |
| Lorem Ipsum Generator | Generador de Lorem Ipsum |
All user-facing strings have been translated to German:
| English | German |
|---|---|
| _About | Über |
| Max Words | Maximale Wörter |
| Max Sentences | Maximale Sätze |
| Paragraphs | Absätze |
| Start with 'Lorem ipsum' | Mit 'Lorem ipsum' beginnen |
| _Generate | _Generieren |
| _Copy to Clipboard | In _Zwischenablage kopieren |
| Copied to clipboard | In Zwischenablage kopiert |
| Lorem Ipsum Generator | Lorem Ipsum Generator |
All user-facing strings have been translated to French:
| English | French |
|---|---|
| _About | À _propos |
| Max Words | Mots maximum |
| Max Sentences | Phrases maximum |
| Paragraphs | Paragraphes |
| Start with 'Lorem ipsum' | Commencer avec 'Lorem ipsum' |
| _Generate | _Générer |
| _Copy to Clipboard | _Copier dans le presse-papiers |
| Copied to clipboard | Copié dans le presse-papiers |
| Lorem Ipsum Generator | Générateur Lorem Ipsum |
All user-facing strings have been translated to Portuguese:
| English | Portuguese (Brazilian) |
|---|---|
| _About | _Sobre |
| Max Words | Máximo de Palavras |
| Max Sentences | Máximo de Frases |
| Paragraphs | Parágrafos |
| Start with 'Lorem ipsum' | Começar com 'Lorem ipsum' |
| _Generate | _Gerar |
| _Copy to Clipboard | _Copiar para a Área de Transferência |
| Copied to clipboard | Copiado para a área de transferência |
| Lorem Ipsum Generator | Gerador de Lorem Ipsum |
All user-facing strings have been translated to Italian:
| English | Italian |
|---|---|
| _About | _Informazioni |
| Max Words | Parole massime |
| Max Sentences | Frasi massime |
| Paragraphs | Paragrafi |
| Start with 'Lorem ipsum' | Inizia con 'Lorem ipsum' |
| _Generate | _Genera |
| _Copy to Clipboard | _Copia negli appunti |
| Copied to clipboard | Copiato negli appunti |
| Lorem Ipsum Generator | Generatore di Lorem Ipsum |
All user-facing strings have been translated to Russian:
| English | Russian |
|---|---|
| _About | _О программе |
| Max Words | Максимум слов |
| Max Sentences | Максимум предложений |
| Paragraphs | Параграфы |
| Start with 'Lorem ipsum' | Начать с 'Lorem ipsum' |
| _Generate | _Генерировать |
| _Copy to Clipboard | _Копировать в буфер обмена |
| Copied to clipboard | Скопировано в буфер обмена |
| Lorem Ipsum Generator | Генератор Lorem Ipsum |
All user-facing strings have been translated to Japanese:
| English | Japanese |
|---|---|
| _About | このアプリケーションについて(_A) |
| Max Words | 最大単語数 |
| Max Sentences | 最大文数 |
| Paragraphs | 段落 |
| Start with 'Lorem ipsum' | 'Lorem ipsum'で始める |
| _Generate | 生成(_G) |
| _Copy to Clipboard | クリップボードにコピー(_C) |
| Copied to clipboard | クリップボードにコピーしました |
| Lorem Ipsum Generator | Lorem Ipsum ジェネレーター |
-
Check locale is installed on your system:
locale -a | grep esIf not listed, install it:
sudo locale-gen es_ES.UTF-8 -
Verify .mo file exists:
ls target/debug/locale/es/LC_MESSAGES/loremgenerator.mo
-
Check environment variables:
echo $LANGUAGE $LC_ALL $LANG
-
Test with verbose output:
LANGUAGE=es RUST_LOG=debug ./target/debug/loremgenerator
If you see warnings during build that msgfmt is not found:
- Install gettext tools (see Requirements section above)
- The application will still build and run, but translations won't be available
Contributions of new translations are welcome! Please:
- Create a new
.pofile for your language - Translate all strings
- Test the translation thoroughly
- Submit a pull request with:
- The new
.pofile - Updated documentation listing the new language
- The new