Initialize other langauges, update README to provide more information, simplify the langauge codes

This commit is contained in:
blitzmann
2020-06-30 23:33:34 -04:00
parent 4d49512a7e
commit 29f6ac0d99
9 changed files with 13662 additions and 29 deletions

View File

@@ -162,7 +162,7 @@ def update_db():
):
newData.append(row)
map = {'typeName_en-us': 'typeName', 'description_en-us': '_description'}
map.update({'description'+v: '_description'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
map.update({'description'+v: '_description'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en'})
_addRows(newData, eos.gamedata.Item, fieldMap=map)
return newData
@@ -170,7 +170,7 @@ def update_db():
print('processing evegroups')
data = _readData('fsd_lite', 'evegroups', keyIdName='groupID')
map = {'groupName_en-us': 'name'}
map.update({'groupName'+v: 'name'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
map.update({'groupName'+v: 'name'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en'})
_addRows(data, eos.gamedata.Group, fieldMap=map)
return data
@@ -178,7 +178,7 @@ def update_db():
print('processing evecategories')
data = _readData('fsd_lite', 'evecategories', keyIdName='categoryID')
map = { 'categoryName_en-us': 'name' }
map.update({'categoryName'+v: 'name'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
map.update({'categoryName'+v: 'name'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en'})
_addRows(data, eos.gamedata.Category, fieldMap=map)
def processDogmaAttributes():
@@ -275,15 +275,15 @@ def update_db():
'name_en-us': 'marketGroupName',
'description_en-us': '_description',
}
map.update({'name'+v: 'marketGroupName'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
map.update({'description' + v: '_description' + v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
map.update({'name'+v: 'marketGroupName'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en'})
map.update({'description' + v: '_description' + v for (k, v) in eos.config.translation_mapping.items() if k != 'en'})
_addRows(data, eos.gamedata.MarketGroup, fieldMap=map)
def processMetaGroups():
print('processing metagroups')
data = _readData('fsd_binary', 'metagroups', keyIdName='metaGroupID')
map = {'name_en-us': 'metaGroupName'}
map.update({'name' + v: 'metaGroupName' + v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
map.update({'name' + v: 'metaGroupName' + v for (k, v) in eos.config.translation_mapping.items() if k != 'en'})
_addRows(data, eos.gamedata.MetaGroup, fieldMap=map)
def processCloneGrades():

View File

@@ -18,13 +18,13 @@ lang = ""
# Maps supported langauges to their suffix in the database
translation_mapping = {
"en_US": "",
"en": "",
"fr": "_fr",
"it": "_it",
"ja": "_ja",
"ko": "_ko",
"ru": "_ru",
"zh_CN": "_zh",
"zh": "_zh",
}
def set_lang(i18n_lang):

View File

@@ -1,4 +1,71 @@
# Pyfa Internationalization(i18n) and Localization(l10n)
# Pyfa Internationalization (i18n) and Localization (l10n)
pyfa provides community-driven translations for the following languages:
* Chinese (locale/zh_CH)
* French (locale/fr_FR)
* Italian (locale/it_IT)
* Japanese (locale/ja_JP)
* Korean (locale/ko_KR)
* Russian (locale/ru_RU)
It is important to keep in mind that pyfa translations are not the same as the translations that come from EVE data. These translations are dumped directly from the game, and the pyfa team has no control over them. This includes, but is not limited to:
* Market browser
* Ship browser
* Item names, description, traits, attributes
If there is a tranlation issue in EVE data, you must submit a ticket to CCP instead.
## Getting involved
Translations are community-driven. The pyfa team isn't going to
1) Maintain individual language packs as a part of general development work, or
2) Delay a release if translations aren't available
This is because the pyfa team is only versed in a few languages, at best. If you are interested in getting involved, then either start a discussion in the language thread (linked above) or, if you're interested in contributing directly, please read the short synopsis of how it works below and submit a Pull Request.
### How it works
A quick introduction to GNU `gettext` translations! There is no programming knowledge required to help with most of the translations. Each langauge that we support has a `LC_MESSAGES/lang.po` file, and in this file there are multiple groups of `msgid` and `msgstr`. `msgid` is usually the English version that is displayed in pyfa, whereas `msgstr` would be the translated version.
```
msgid "Click to toggle between effective HP and raw HP"
msgstr "点击切换有效HP和原始HP"
```
90% of translations are as simple as that. The other 10% may require you to take a quick dip into the code to tweak the formatting of the string, assign context prefixs (for translations that may translate differently for the same work due to context), or to even add the annotation to the string that will expose it to the translation engine. If you're not comfortable with that, you can always request it!
### POEdit
[Poedit](https://poedit.net/) offers a nice GUI for updating translations.
##### To update PO file for existing translation
1. open a existing `locale/ll_CC/LC_MESSAGES/lang.po`
2. *Catalog* -> *Update form POT file*
3. select pre-prepared `lang.pot` file
##### To translate and generate MO file
edit the translation and hit Save :)
## FAQ
Q: The English text isn't in the `.po` file for me to translate<br />
A: This is probably one of two things:
1. Missing annotations in the source code. All text that needs to be translated needs to be wrapped with `_t()` to make it locale-aware
2. Out of date `.po` file. As pyfa development continues, the `.po` file may fall behind. See next question.
Q: How do I update the `.po` file for my language?<br />
A: See `Commands` section below for a number of useful commands
Q: I run pyfa in Linux but the translations don't work<br />
A: If you're running from source / your own method, this is because the `.mo` files aren't checked into the repo and thus aren't available by default. Running `python3 scripts\compile_lang.py` should compile all language files. If you're running from a package from a third-party repository, YMMV - please contact the maintainer of that package.
## Commands
Below is a summary of [GNU gettext](https://www.gnu.org/software/gettext/) manual, adapted for Pyfa i18n workflow.
@@ -26,7 +93,7 @@ explanation:
* `-f -`: let `xgettext` to read from stdin, which is connected to `find` stdout
* `-s`: sort output according to `msgid`
this `locale/lang.pot` is called PO template, which is throwed away once actual `ll_CC/LC_MESSAGES/lang.po` is ready for use.
this `locale/lang.pot` is called PO template, which is discarded once actual `ll_CC/LC_MESSAGES/lang.po` is ready for use.
### To initialize PO file for new language
@@ -43,7 +110,7 @@ explanation:
* `LC_MESSAGES`: GNU gettext conventional path to search for localized messages
* `lang.po`: language domain and file format
this `locale/ll_CC/LC_MESSAGES/lang.po` should be checked into VCS, later it will be converted into mechine readable format (MO).
this `locale/ll_CC/LC_MESSAGES/lang.po` should be checked into VCS, later it will be converted into mechine readable format (`.mo`).
### To update PO file for existing translation
@@ -53,7 +120,7 @@ $ msgmerge -s locale/ll_CC/LC_MESSAGES/lang.po locale/lang.pot
### To do actual translation
just edit the `lang.po` file :)
just edit the `lang.po` file, either manually or via GUI applications like POEdit
### To generate machine readable MO file
@@ -63,12 +130,14 @@ For a single locale:
$ msgfmt locale/ll_CC/LC_MESSAGES/lang.po -o locale/ll_CC/LC_MESSAGES/lang.mo
```
For all available locale:
For all available locales:
```bash
for f in locale/*/; do
msgfmt $f/LC_MESSAGES/lang.po -o $f/LC_MESSAGES/lang.mo
done
```
Since compiling `.po` files is useful to everyone, we also have a script in the repo that can do it without the need for the normal `gettext` tools:
`python3 scripts/compile_lang.py`
### To merge 2 or more PO file
@@ -79,14 +148,3 @@ $ msgcat -s path/to/old.po [path/to/another.po] -o path/to/new.po
Note that `msgcat` cannot perform a 3-way merge, it will simply stack translations with same `msgid` on top of each other.
If you use `msgcat` to merge multiple PO file, please check and fix the output before commit to Git.
## i18n with Poedit
### To update PO file for existing translation
1. open a existing `locale/ll_CC/LC_MESSAGES/lang.po`
2. *Catalog* -> *Update form POT file*
3. select pre-prepared `lang.pot` file
### To translate and generate MO file
edit the translation and hit Save :)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -538,13 +538,17 @@ class GraphSettings:
class LocaleSettings:
_instance = None
DEFAULT = "en_US"
DEFAULT = "en"
supported_langauges = {
"en_US": wx.LANGUAGE_ENGLISH_US,
"zh_CN": wx.LANGUAGE_CHINESE_SIMPLIFIED,
# todo: add the others that EVE supports
}
"en": wx.LANGUAGE_ENGLISH_US,
"fr": wx.LANGUAGE_FRENCH,
"it": wx.LANGUAGE_ITALIAN,
"ja": wx.LANGUAGE_JAPANESE,
"ko": wx.LANGUAGE_KOREAN,
"ru": wx.LANGUAGE_RUSSIAN,
"zh": wx.LANGUAGE_CHINESE_SIMPLIFIED,
}
@classmethod
def getInstance(cls):