https://github.com/vulcan-dev/gettext-gen
Automation utility for gettext
https://github.com/vulcan-dev/gettext-gen
c cpp languages localization python
Last synced: 4 months ago
JSON representation
Automation utility for gettext
- Host: GitHub
- URL: https://github.com/vulcan-dev/gettext-gen
- Owner: vulcan-dev
- License: mit
- Created: 2023-10-18T17:16:39.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-18T19:12:22.000Z (over 1 year ago)
- Last Synced: 2025-01-10T21:32:35.495Z (6 months ago)
- Topics: c, cpp, languages, localization, python
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gettext-gen
## Usage:
```
gen_localization.py [-h] [-t]
-h, --help show this help message and exit
-t, --translate Whether or not to auto-translate missing fields
-c, --config Creates default .env
```When you download this, rename `.env.example` to `.env` and then modify it to your choosing.
Most options can be modified in the `.env` file, but in order to change the files `xgettext` scans, you will need to modify the `files` list in the python file.## Requirements
You will need to have the following in your path:
- xgettext
- msgfmt
- msginit
- msgmergeYou can get these for both Linux and Windows.
On Linux, use your package manager.
On Windows, you can get it from quite a few places, here's one: https://gnuwin32.sourceforge.net/packages/gettext.htm## Automatic Translation
Add the following to your `.env` file:
```
DEEPL_KEY=YOUR_KEY_HERE
```
Once done, you can run the script with `-t` or `--translate`.
Note: It will only translate fields that haven't already been translated. If you would like to have it translate again, clear the `msgstr` so it looks like: `msgstr ""`## Manual Translation
To manually translate, just edit the `.po` files and then run the script again. It will build it and move the built files to their correct locations.---
## Notices
It throws warnings if you do something like:
```cpp
gettext("Hello World!\n");
```
Don't add newlines like this for now, even though I think it still works.
I recommend doing the following:
```cpp
#define STR_MYTEXT _("My Text")
```