Hi,
Sorry about the delays...
Post by James TurnerMy action / key-binding changes are close to working, will try to
finish them this weekend. They will really benefit from the
- actions have a unique id: âtoggle-parking-brakeâ or âengage-ap-heading-modeâ
- based on this I expect to lookup ideally both a name and a
get_locale()->getLocalizedString(actionid, âaction-nameâ)
get_locale()->getLocalizedString(actionid, âaction-descriptionâ)
?
if (action->toggleState())
get_locale()->getLocalizedString(actionid + â-on", âaction-nameâ)
else
get_locale()->getLocalizedString(actionid + â-off", âaction-nameâ)
This is to allow action items like âenter full-screen modeâ to become âexit full-screen modeâ and similar to be done nicely.
Does this sound feasible? Iâm not sure how we generate the list of action-ids, so that translations can find them? They will be defined in FG_DATA/actions.xml but aircraft might add their own in special situations, I would hope thatâs rare though. (They will work much better if there are defined centrally, and aircraft simply hook into them but keep the same ID, which is supportedâŠ) I guess we canât escape aircraft needing to supply translations in some cases however, Thorsten also asked about aircraft-specific startup tipsâŠ.
It's difficult for me to answer the API questions without a clear
picture of how the translatable strings are going to be extracted and
merged.
First, to be clear, since you wrote âyour APIâ, the
EmbeddedResourceManager locale feature was not meant to select
translatable strings according to the locale (I don't know if that is
what you had in mind, but otherwise I don't know what you meant by âyour
APIâ [i.e., mine]). This feature mimics the corresponding one in Qt's
rcc tool and associated format: it selects a *whole* resource based on
the locale (and of course based on the resource virtual path).
The example for this feature given in Qt's documentation of the RCC
format is a locale-dependent icon. Another possibility would be a README
file (or XML) translated in several languages. But it doesn't address
the problem of detecting outdated translations. The only thing it does
is select the âbestâ version of a resource according to the locale
(e.g., "fr_FR", then if not found "fr", then if still not found the
default locale ""). But if this localized resource is outdated wrt the
English version, that's too bad.
Yes, in theory a short string (thinking of typical localized messages of
a program) can be registered and retrieved the same as a README file,
but the infrastructure wasn't designed for this, and I'm not sure it's a
good fit. The locale fallback algorithm is rather simple and can be
copy-pasted to a more specialized infrastructure if that's really the
thing... which I doubt. :)
More to the problems you evoked: we need to know how translatable
strings will be extracted and merged. For C++ files, there are usually
already-written tools that extract function calls like _(), tr() or
tr_noop(). I think you know that. Function names depend on the
framework, the last one I used was gettext, it supports several parsed
languages (C, Python...) and the special function names can be chosen
via cmdline args, including whether they take additional parameters for
plural forms and things like that---this is the xgettext program, but
it works with .po, not XLIFF AFAIK.
My main concern here is that you seem to want translatable strings in FG
XML files. How do we extract them and merge them with existing
translations? Extracting can be done by custom parsing of the XML file,
of course, but then you have to detect fuzzy strings (already-translated
strings whose English version has been updated) and those that have
disappeared. This doesn't sound trivial without a good library or
special-purpose tool (for XLIFF).
The other things you mentioned (additional string-selection âknobsâ) can
probably be addressed with context attributes of the XLIFF format, but
one has to check if all tools we'll need properly deal with such
attributes the way they are used. I'm saying this in particular because
the main motivation behind XLIFF 2.0 seems to be that XLIFF 1.2 was too
complex and sometimes ambiguous, with the result that âthe majority of
XLIFF 1.2 implementations today [on Aug 27, 2014] are not completeâ[1].
Attaching the script I mentioned in private (plain text output just to
show that the input works). It's in Python 3.
Regards
[1] http://info.moravia.com/blog/bid/354057/What-s-So-Sexy-About-XLIFF-2-0
--
Florent