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

2020-05-18 Thread Troy A. Griffitts
Right, so, it's going to be different per module, so I would do something like:

VerseKey *vk = (VerseKey *)currentBible->getKey();

for ((*vk) = TOP; !vk->popError(); vk->setBook(vk->getBook() + 1)) {
  cout << vk->getBookAbbrev();
}

On May 17, 2020 11:27:32 PM MST, Tobias Klein  wrote:
>On 5/15/20 8:22 PM, Troy A. Griffitts wrote:
>> 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.
>
>Let me explain my actual use case.
>
>After doing a module search I'm generating a bar chart that visualizes 
>search results per bible book. It looks like this at the moment:
>https://paste.pics/073e805fc1a74db1e7899aefaf838e86
>
>In that bar chart I'm using the book abbreviations as labels on the 
>x-axis of the chart. I'm simply using the abbreviations, because the 
>full book names would take up too much vertical screen space in this 
>particular case.
>
>That's why I was asking for a direct method for translating the Abbrev.
>
>strings, since I don't need the abbreviations for individual verses 
>(then the VerseKey based approach would totally make sense), but in
>this 
>case I simply need to generate an array with all the book names 
>(abbreviations) to use as labels for the x-axis of the chart.)
>
>I can work with the existing API, but for this particular use case it's
>
>certainly a bit odd (from an object-oriented standpoint), because I'm 
>not dealing with individual verses in this case.
>
>Best regards,
>Tobias
>
>
>___
>sword-devel mailing list: sword-devel@crosswire.org
>http://www.crosswire.org/mailman/listinfo/sword-devel
>Instructions to unsubscribe/change your settings at above page

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.___
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

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

2020-05-18 Thread Tobias Klein

On 5/15/20 8:22 PM, Troy A. Griffitts wrote:
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.


Let me explain my actual use case.

After doing a module search I'm generating a bar chart that visualizes 
search results per bible book. It looks like this at the moment:

https://paste.pics/073e805fc1a74db1e7899aefaf838e86

In that bar chart I'm using the book abbreviations as labels on the 
x-axis of the chart. I'm simply using the abbreviations, because the 
full book names would take up too much vertical screen space in this 
particular case.


That's why I was asking for a direct method for translating the Abbrev. 
strings, since I don't need the abbreviations for individual verses 
(then the VerseKey based approach would totally make sense), but in this 
case I simply need to generate an array with all the book names 
(abbreviations) to use as labels for the x-axis of the chart.)


I can work with the existing API, but for this particular use case it's 
certainly a bit odd (from an object-oriented standpoint), because I'm 
not dealing with individual verses in this case.


Best regards,
Tobias


___
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

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

2020-05-16 Thread Tobias Klein

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 
Contributor=Ulrich Schmid 

[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" 
*An:* "SWORD Developers' Collaboration Forum" 

*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 mailto:cont...@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@crosswire.org
<mailto:sword-devel@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@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@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page


___
sword-devel mailing list:swo

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

2020-05-15 Thread Troy A. Griffitts
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 
Contributor=Ulrich Schmid 

[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" 
>> *An:* "SWORD Developers' Collaboration Forum" 
>> *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 > <mailto:cont...@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@crosswire.org
>> <mailto:sword-devel@crosswire.org>
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
>>
>> ___ sword-devel mailing
&

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

2020-05-15 Thread Tobias Klein

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" 
*An:* "SWORD Developers' Collaboration Forum" 
*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 mailto:cont...@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@crosswire.org
<mailto:sword-devel@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@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@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@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

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

2020-05-15 Thread Peter Von Kaehne
 


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" 
An: "SWORD Developers' Collaboration Forum" 
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 <cont...@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@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@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@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

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

2020-05-15 Thread Tobias Klein
Hi,

Any feedback regarding this question?
I would appreciate it!

Best regards,
Tobias

> Am 10.05.2020 um 12:45 schrieb Tobias Klein :
> 
> 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@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@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

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

2020-05-10 Thread Tobias Klein

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@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page