Currently (version 19.12), all object info and examples localizations are useless. This patch fixes current way of extracting and using Step translations.
Details
- Extraction works. However, I'm uncertain if it is worth to have separate catalogs for object infos and examples (please, give an advice).
- Translation (when put into the common /po dir) compiles and works. Translations are installed into the objinfo/<locale> dir to avoid conflicts with current lag packs. It is tested that Step can display the compiled localized HTML files.
Screenshot with translated tutorial and infobrowser (Ukrainian, clean install):
Diff Detail
- Repository
- R341 Step
- Branch
- master
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 18950 Build 18968: arc lint + arc unit
step/infobrowser.cc | ||
---|---|---|
158 | In my opinion, I would prefer to stick with the resource-based location for the un-translated HTML files. This makes the development setup (slightly) simpler because no XDG_DATA_DIRS variable must be set and the default handling is easier to break. Actually, the default HTML files would be a fallback even if the environment variables are set incorrectly. |
Remove remnants of objinfo HTML installation for English (not needed as we use internal resources)
step/infobrowser.cc | ||
---|---|---|
156–159 | I think using KLocalizedString::languages() here makes more sense, i think QLocale uses a bit of a different naming system for "complex" stuff like pt_BR |
How does the STEP_BUILD_TRANSLATIONS thing work? Does one have to enable it manually?
I see some code like
if(CURRENT_LANG) set(STEP_BUILD_TRANSLATIONS 1) endif(CURRENT_LANG)
Does it mean that you can only build one language at a time?
Yes. That's written in the Phabricator review request description. You should explicitly add -DSTEP_BUILD_TRANSLATIONS=true to the cmake command to process the translations. I'm not a big CMake expert, but it should also work without these "if"s because of "foreach".
I see some code like
if(CURRENT_LANG) set(STEP_BUILD_TRANSLATIONS 1) endif(CURRENT_LANG)Does it mean that you can only build one language at a time?
No. I tested it to build for all the languages that have corresponding files in /po (e.g. uk and de) . The code you've mentioned has actually been *removed" from CMakeLists.txt.
Does this work cmake wise if there's no po/ folder?
step/infobrowser.cc | ||
---|---|---|
156–159 | can i convince you to iterate over KLocalizedString::languages instead of using the first one only? This way we will try all the langauges you may have selected and then only fallback to english if none was found |
step/infobrowser.cc | ||
---|---|---|
156–159 |
or even better, use KLocalizedString::localizedFilePath() to locate the translated html file? |
Implemented.
I do not know how to implement Pino's proposal. Can I beg you for an example and just a few words on why it is better? Thanks in advance.
So far, the only usage of KLocalizedString::localizedFilePath() I could find is KMyMoney.
@pino Is it acceptable not to use this rare API here?
It's rare because people don't use it.
QString KLocalizedString::localizedFilePath ( const QString & filePath )
static
Find a path to the localized file for the given original path.
It means you don't need to iterate at all: you just say "give me the localized file path", one line instead of the cycle on lines 156-168.
But as it was said, the structure of the translated files needs to be changed (objinfo/<lang> -> objinfo/l10n/<lang>), which means that the cmake file should be adapted to follow that structure.
Use KLocalizedString::localizedFilePath(). As it is incompatible with internal resources, install English default HTML files and remove resource embedding again (sorry, Andreas).
@ltoscano BTW, should extractxml script be ported to Python 3 in this Phabricator review to work with our translation system? Can it be done later?
No need to change it here - we have definitely more work to do to switch every script to Python 3.
Sorry for disturbing, but
- Will there be further reviews?
- Can this be pushed to 19.12 branch to enable translations there?
Thanks in advance for your answers.