[sword-devel] How to get translated book abbreviations with LocaleMgr?

Tobias Klein contact at tklein.info
Sat May 16 12:28:13 MST 2020


Thanks, Troy. This is helpful!
I'll look into this tomorrow.

Best regards,
Tobias

On 5/15/20 8:22 PM, Troy A. Griffitts wrote:
>
> Sorry, I forgot to respond to this.
>
> Yes, you can have a look at sword/tests/parsekey.cpp
>
> But basically, while you can directly use LocaleMgr to translate any 
> strings, even strings in your application if you augment SWORD's 
> locale's with your application string with something like:
>
> LocaleMgr::getSystemLocaleMgr()->loadConfigDir(SWBuf("~/.myapp/locales.d");
>
> .. only the [Text] section is used directly for the translate method.  
> E.g., if your application has some strings you'd like to add to 
> SWORD's translatable strings, for German, you might add a file:
>
> # ~/.myapp/locales.d/de-utf8.conf
> #
>
> [Meta]
> Name=de
> Description=Deutsch (Unicode)
> Encoding=UTF-8
> Contributor=Justin Bellars <jbellars at gmail.com>
> Contributor=Ulrich Schmid <schmid.ub at googlemail.com>
>
> [Text]
> View=Abrufen
> Bibles=Bibeln
> Language Assist=Sprachförderung
> Commentary Assist=Kommentarförderung
> Verse Study=Vers-für-Vers-Analyse
> Bookmarks=Lesezeichen
>
> ...
>
> Any strings in this section will be available to LocaleMgr's translate 
> method, including all the ones that come default with SWORD.
>
> The other sections (sections besides [Text] in SWORD's locale files 
> are not specifically for directly translation.  They are used by 
> SWORD's verse parser VerseKey translation, etc.
>
> The typically way an app uses all this is (not usually all in one 
> place each time they want a translated book name, but for ordering 
> purposes all in one place...):
>
> const char *usersPreferredLocaleName = "de"
> const char *bookTerm = "Gen";
> const char *activeBibleName = "KJVA";
>
> LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(usersPreferredLocaleName);
>
> SWMgr library;
> SWModule *bible = library.getModule(activeBibleName);
>
> VerseKey *vk = (VerseKey *)bible->getKey();
> vk->setText(bookTerm);
>
> std::string translatedAbbreviation = vk->getBookAbbrev();
>
>
> In summery, usually a user's preferred locale is set systemwide.  Then 
> everything is generally switched to that locale, i.e., VerseKey output 
> will be in that locale so when you getBookAbbrev, you will get German.
>
> You can do lower level work if you'd like.  SWKey has a setLocale 
> method if you'd like to set just a single key to a different 
> language.  But typically our frontends set default locale systemwide 
> before constructing SWMgr.
>
> Hope this helps,
>
> Troy
>
>
>
> On 5/15/20 10:38 AM, Tobias Klein wrote:
>>
>> Hi Peter,
>>
>> Why is it then that mapping tables like this one are kept in the 
>> locales.d files:
>>
>> [Pref Abbrevs]
>> Gen=1Mo
>> Exod=2Mo
>> Lev=3Mo
>> Num=4Mo
>> Deut=5Mo
>> Josh=Jos
>> Judg=Rich
>> Ruth=Rut
>> 1Sam=1Sam
>> 2Sam=2Sam
>> 1Kgs=1Kön
>> 2Kgs=2Kön
>> 1Chr=1Chr
>> 2Chr=2Chr
>> Ezra=Esr
>> Neh=Neh
>>
>> This is the info I need. I'm just wondering how to extract that 
>> information with the SWORD API.
>>
>> Best regards,
>> Tobias
>>
>> On 5/15/20 7:19 PM, Peter Von Kaehne wrote:
>>> I think the lack of response is as there is no sensible way of 
>>> responding.
>>>
>>> The whole construct of abbreviations (irrespective of languages) is 
>>> uniderectional (Abbr->Book name). The same applies to English. What 
>>> you mix up here is that a particular subset of English abbreviations 
>>> is also the set of OSIS identifiers.
>>>
>>> Peter
>>> *Gesendet:* Freitag, 15. Mai 2020 um 18:03 Uhr
>>> *Von:* "Tobias Klein" <contact at tklein.info>
>>> *An:* "SWORD Developers' Collaboration Forum" 
>>> <sword-devel at crosswire.org>
>>> *Betreff:* Re: [sword-devel] How to get translated book 
>>> abbreviations with LocaleMgr?
>>> Hi,
>>> Any feedback regarding this question?
>>> I would appreciate it!
>>> Best regards,
>>> Tobias
>>>
>>>     Am 10.05.2020 um 12:45 schrieb Tobias Klein <contact at tklein.info
>>>     <mailto:contact at tklein.info>>:
>>>
>>>     Hi,
>>>
>>>     how can I use the LocaleMgr to get a translated book abbreviation?
>>>
>>>     For some reason this code did not work for me:
>>>
>>>     sword::SWLocale* locale = this->_localeMgr->getLocale(localeCode);
>>>     std::string translatedAbbreviation =
>>>     std::string(locale->translate(bookTerm));
>>>
>>>     I was using "de" as a locale and "Gen" as the term to be
>>>     translated, but I did not get the german variant of "Gen", but
>>>     rather the exact same term "Gen" as a result.
>>>
>>>     Best regards,
>>>     Tobias
>>>
>>>     _______________________________________________
>>>     sword-devel mailing list: sword-devel at crosswire.org
>>>     <mailto:sword-devel at crosswire.org>
>>>     http://www.crosswire.org/mailman/listinfo/sword-devel
>>>     Instructions to unsubscribe/change your settings at above page
>>>
>>> _______________________________________________ sword-devel mailing 
>>> list: sword-devel at crosswire.org 
>>> http://www.crosswire.org/mailman/listinfo/sword-devel Instructions 
>>> to unsubscribe/change your settings at above page
>>>
>>> _______________________________________________
>>> sword-devel mailing list:sword-devel at crosswire.org
>>> http://www.crosswire.org/mailman/listinfo/sword-devel
>>> Instructions to unsubscribe/change your settings at above page
>>
>> _______________________________________________
>> sword-devel mailing list:sword-devel at crosswire.org
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20200516/90c95113/attachment-0001.html>


More information about the sword-devel mailing list