Commit Graph

25 Commits

Author SHA1 Message Date
Florent Rougon
b42f543b93 i18n.py: print the problematic 'trans-unit' id when aborting
It's much easier to locate an error in a .XLF file when one has the id
of the 'trans-unit' element that causes the problem.
2021-08-04 00:07:55 +02:00
Automatic Release Builder
28de5426f2 Localized catalogs: fix name/description bug 2020-06-22 10:02:40 +01:00
Florent Rougon
8028ce2888 Python: move test modules and data to python3-flightgear/flightgear/meta/tests/
- Move test_catalog.py, test_sgprops.py and catalog/testData/ to
  python3-flightgear/flightgear/meta/tests/.
- Copy catalog/fgaddon-catalog/ to the same place (it is needed by
  test_catalog.py).
- Adapt test_catalog.py and test_sgprops.py accordingly.
- Remove the executable bits from test_catalog.py and test_sgprops.py:
  this is because test_catalog.py can't be run directly anymore; well,
  it can but 3 tests would fail in this setup. No time to investigate
  why (sorry), but this commit adds a README.txt in
  python3-flightgear/flightgear/meta/tests/README.txt that explains how
  to run the tests in a way that works (basically, run
  'python3 -m unittest' from the python3-flightgear directory).

For a bit more context, see
<https://sourceforge.net/p/flightgear/mailman/message/37042247/>.
2020-06-22 00:30:51 +02:00
Automatic Release Builder
cef19a8b13 Catalog I18N support
Read I18N satrings form aircraft data and add to the catalog
2020-06-21 19:25:18 +01:00
Florent Rougon
3a36bdd474 i18n: move the scripts to the top-level 'i18n' directory
Also add a README.md to python3-flightgear explaining how to use the
PYTHONPATH environment variable or a .pth file in order to run the
Python scripts in FGMeta, and pointing to the top-level directories
'catalog' and 'i18n'.
2020-06-19 18:26:43 +02:00
Florent Rougon
b86452cf08 fg-copy-weather-scenarios-to-default-locale: adjust the sgprops import 2020-06-19 18:15:30 +02:00
Florent Rougon
1c2d17d869 Reorganize catalog modules
- Move the support modules inside python3-flightgear/flightgear/ and
  remove their shebang, if any.
- Accordingly adapt the import statements.
- Change shebangs from e.g. '#! /usr/bin/python' to
  '#! /usr/bin/env python3'.
- Small changes to make Python 3 happy with all scripts.

catalog/check_aircraft.py should be run under Python 3 from now on.
2020-06-19 18:15:25 +02:00
Florent Rougon
d259ec0b76 i18n Python scripts: improve fg-copy-weather-scenarios-to-default-locale
- Use the new flightgear.meta.strutils.simplify() function.
- Automatically add a comment to the generated file to indicate that it
  was automatically generated and shouldn't be manually modified, etc.
- Improve error handling: abort with a clear error message if any of the
  'id', 'name' and 'desc' children of a 'scenario' element is
  problematic (empty or missing, for instance).
- Rename make_xml_leaf() to makeXmlLeaf() + other minor renaming.
2020-06-18 14:23:03 +02:00
Florent Rougon
52e84741d0 i18n Python scripts: add module flightgear.meta.strutils
For now, the module only contains the simplify() function, which will be
used by fg-copy-weather-scenarios-to-default-locale.
2020-06-18 14:22:57 +02:00
Automatic Release Builder
c2a241c357 Review feedback from Florent 2020-06-18 10:16:06 +01:00
Florent Rougon
120d02e5fb i18n Python scripts: rename BasicL10NResourceManager._readFgResourceFile()
Class method BasicL10NResourceManager._readFgResourceFile() was not
meant to be private; remove the leading underscore.
2020-06-18 01:06:37 +02:00
Florent Rougon
14eb302022 i18n Python scripts: fix a typo in TranslationUnit._stringsKey()
I believe the problematic code could only be reached when reading buggy
versions (i.e., with duplicate ids) of the legacy FlightGear XML
non-master l10n files, which is why we haven't tripped on it so far.
2020-06-18 00:56:37 +02:00
Automatic Release Builder
d502afa171 Add weather-scenarios to i18n list 2020-06-17 17:08:50 +01:00
Automatic Release Builder
14b3950d44 Script to create default translation for weather 2020-06-17 17:03:25 +01:00
Florent Rougon
eabc8534b0 i18n Python scripts: define the list of basic categories at the top
Introduce a BASIC_CATEGORIES variable at the top of
python3-flightgear/flightgear/meta/i18n.py that lists all categories
handled by BasicL10NResourceManager. Since currently all of our
translation files can be handled this way (the XML master files all have
a flat structure), we only need to say BASIC_CATEGORIES = CATEGORIES.

With this change, adding a new basic category such as
'weather-scenarios' only requires one to add it to CATEGORIES.
2020-06-17 13:12:31 +02:00
Florent Rougon
b3893f7bda i18n Python scripts: allow autodetection of translation files
- Add class method availableTranslations() to AbstractFormatHandler in
  i18n.py.

- Use it in fg-update-translation-files to allow autodetection of the
  available translations when no LANGUAGE_CODE is passed to
  fg-update-translation-files.

This should address James' wish at
<https://sourceforge.net/p/flightgear/mailman/message/37003967/>.
2020-05-08 10:33:35 +02:00
Florent Rougon
69033f37f8 i18n Python scripts: declare plural forms for Catalan and Slovak
Regarding Slovak language, there was enough info in
<https://code.qt.io/cgit/qt/qttools.git/tree/src/linguist/shared/numerus.cpp>.
As for Catalan, I don't see anything there, so I put
"ca": ["singular", "plural"] based on the fact that [1] says:

  "Catalan has an inflectional grammar. Nouns have two genders
   (masculine, feminine), and two numbers (singular, plural)."

I suspect we'll be ahead of Qt Linguist for Catalan.

[1] https://en.wikipedia.org/wiki/Catalan_language
2020-04-15 11:40:26 +02:00
Florent Rougon
a5525ba2b3 i18n Python scripts: remove class SysL10NResourceManager from i18n.py
This class isn't needed anymore now that
$FG_ROOT/Translations/default/sys.xml has a flat structure, like the
other FG XML i18n files that define the default translation. This is
related to

  6d6e1809f0/

and more specifically to

  587c601345/
2018-10-12 08:14:01 +02:00
Florent Rougon
359152c8d1 i18n Python scripts: fix Translation.__setitem__() and add docstrings
Translation.__setitem__() from flightgear/meta/i18n.py isn't used
anywhere here (it is not very useful), so no harm done, but that could
have confused potential readers.
2018-10-11 20:32:48 +02:00
James Turner
2c41742b99 Add Russian to the language list
Fix provided by Michael Danilov
2018-10-11 13:26:58 +01:00
Florent Rougon
e9ebb418f3 python3-flightgear/README-l10n.txt: add a little hint 2018-01-19 12:51:55 +01:00
Florent Rougon
7142621966 i18n Python scripts: add script fg-merge-xliff-into-xliff
This script is designed for the following use case:

Suppose a translator has been working on a particular translation file,
and meanwhile the official XLIFF file for this translation has been
updated in FGData (new translatable strings added, obsolete strings
marked or removed, etc.). In such a case, 'fg-merge-xliff-into-xliff'
can be used to merge the translator's work into the official XLIFF
translation file. Essentially, this means that for all strings that have
the same source text, plural status, number of plural forms and of
course target language, the target texts, "approved" status and
translator comments will be taken from the first file passed in the
following command:

  fg-merge-xliff-into-xliff TRANSLATOR_FILE PROJECT_FILE

Used like this, PROJECT_FILE will be updated with data from
TRANSLATOR_FILE. If you don't want to modify PROJECT_FILE, use the -o
(--output) option. If '-' is passed as argument to this option, then the
result is written to the standard output.
2017-09-19 22:11:41 +02:00
Florent Rougon
54d6196698 i18n Python scripts: minor changes
- Remove unnecessary imports

  These imports were a leftover from early versions; now, they are done
  in modules such as flightgear.meta.i18n and don't need to be in the
  calling scripts anymore.

- Fix an exception message
2017-09-17 16:18:06 +02:00
Florent Rougon
3acff3caba Initial version of rebuild-fgdata-embedded-resources
This is a simple Python 3 script to ease rebuilding of FGData embedded
resources for FlightGear. It uses fgrcc in conjunction with
<FlightGear-repo>/src/EmbeddedResources/FGData-resources.xml and the
FGData files mentioned therein to (re)create the FGData-resources.[ch]xx
files used in the FlightGear build. The existing files in the FlightGear
repository are always overwritten (namely, FGData-resources.[ch]xx in
<FlightGear-repo>/src/EmbeddedResources).

There are command-line options (--flightgear, --fgdata and --fgrcc) to
indicate where the FlightGear and FGData repositories, as well as the
fgrcc executable can be found. However, it is most convenient to put
these paths once for all in the config file
$HOME/.fgmeta/rebuild-fgdata-embedded-resources.json (use
'rebuild-fgdata-embedded-resources --help' to see an example). This way,
you can invoke the script without any argument whenever you want to
update <FlightGear-repo>/src/EmbeddedResources/FGData-resources.[ch]xx.

This script doesn't depend on any module out of the Python standard
library (intentionally, in case distributors want to use it to recreate
themselves the FGData-resources.[ch]xx files). It should work on Python
3.5 and later versions.
2017-08-18 13:41:21 +02:00
Florent Rougon
c6eb59eb42 Initial version of the Python scripts to manage l10n using the XLIFF format
Add the following files:

  python3-flightgear/README-l10n.txt
  python3-flightgear/fg-convert-translation-files
  python3-flightgear/fg-new-translations
  python3-flightgear/fg-update-translation-files
  python3-flightgear/flightgear/__init__.py
  python3-flightgear/flightgear/meta/__init__.py
  python3-flightgear/flightgear/meta/exceptions.py
  python3-flightgear/flightgear/meta/i18n.py
  python3-flightgear/flightgear/meta/logging.py
  python3-flightgear/flightgear/meta/misc.py

They should work on Python 3.4 and later (tested with 3.5.3). The folder
structure is chosen so that other FG support modules can insert
themselves here, and possibly be used together. I put all of these
inside 'flightgear.meta', because I don't expect them to be needed at FG
runtime (neither now nor in the future), probably not even by the CMake
build system.

To declare that a string has plural forms, simply set the attribute
'with-plural' to 'true' on the corresponding element of the default
translation (and as in Qt, use %n as a placeholder for the number that
determines which singular or plural form to use).
2017-08-04 23:39:05 +02:00