Localized Basic macros

classic Classic list List threaded Threaded
6 messages Options
Johnny Rosenberg Johnny Rosenberg
Reply | Threaded
Open this post in threaded view
|

Localized Basic macros

Hi!
I'm playing a little with macros (my level is probably one step or two
above beginner) and making extensions out of them. I found a few examples
online and I got it to work.

I don't know if I'm going to share anything in the future (because I don't
think my extensions will fulfil anyone else's needs than my own and they
are probably poorly written anyway), but if I want to do that, there's a
minor problem: My macros interact with the user (usually me) in Swedish,
and I guess it would be a good idea to at least write an English version
for sharing with others.

However, it would be nice if the extension adapts to the user's locale when
installed (and falls back to English when the user's locale is not
available, that is in most cases). Is that possible? A link to some guide
of some sort would be appreciated. I found nothing so far.

Experimenting with the stuff gave me nothing yet. All I came up with is a
box in the Basic IDE in which I can select a language, but I'm not sure how
to use it. After adding some languages I can now select en-US and sv-SE,
but then what? Should I just copy all of the code to a new module,
translate everything there and select the language I used in that box?

And what do I need to do when packaging the whole thing? I realised a few
things. For instance in the Addons.xcu file, I can use several different
languages for the tool tip text like so:
<value xml:lang="en">My description</value>
<value xml:lang="sv-SE">Min beskrivning</value>

But in my library folder (the one LibreOffice created for me when exporting
as Basic library), there are three files:
dialog.xlb
MyMacro.xba
script.xlb
If I want to use several languages, what would happen here? Or would there
be one ”library” for each language?

So, obviously I haven't grasped the concept for this at all yet. Any hints?



Kind regards

Johnny Rosenberg

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Regina Henschel Regina Henschel
Reply | Threaded
Open this post in threaded view
|

Re: Localized Basic macros

Hi Johnny,

Johnny Rosenberg schrieb am 10-May-20 um 14:35:

> Hi!
> I'm playing a little with macros (my level is probably one step or two
> above beginner) and making extensions out of them. I found a few examples
> online and I got it to work.
>
> I don't know if I'm going to share anything in the future (because I don't
> think my extensions will fulfil anyone else's needs than my own and they
> are probably poorly written anyway), but if I want to do that, there's a
> minor problem: My macros interact with the user (usually me) in Swedish,
> and I guess it would be a good idea to at least write an English version
> for sharing with others.
>
> However, it would be nice if the extension adapts to the user's locale when
> installed (and falls back to English when the user's locale is not
> available, that is in most cases). Is that possible? A link to some guide
> of some sort would be appreciated. I found nothing so far.

Perhaps start with the help
https://help.libreoffice.org/latest/en-GB/text/sbasic/guide/translation.html

Info from OpenOffice.org might be still valid:
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Dialog_Localization

There had been some issues with localization of dialogs:
According to https://bugs.documentfoundation.org/show_bug.cgi?id=130932 
you need at least LO version 6.4.

And this issue is not yet solved:
https://bugs.documentfoundation.org/show_bug.cgi?id=100792
It contains a test document.

Kind regards
Regina


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Johnny Rosenberg Johnny Rosenberg
Reply | Threaded
Open this post in threaded view
|

Re: Localized Basic macros

Den sön 10 maj 2020 kl 15:29 skrev Regina Henschel <[hidden email]
>:

> Hi Johnny,
>
> Johnny Rosenberg schrieb am 10-May-20 um 14:35:
> > Hi!
> > I'm playing a little with macros (my level is probably one step or two
> > above beginner) and making extensions out of them. I found a few examples
> > online and I got it to work.
> >
> > I don't know if I'm going to share anything in the future (because I
> don't
> > think my extensions will fulfil anyone else's needs than my own and they
> > are probably poorly written anyway), but if I want to do that, there's a
> > minor problem: My macros interact with the user (usually me) in Swedish,
> > and I guess it would be a good idea to at least write an English version
> > for sharing with others.
> >
> > However, it would be nice if the extension adapts to the user's locale
> when
> > installed (and falls back to English when the user's locale is not
> > available, that is in most cases). Is that possible? A link to some guide
> > of some sort would be appreciated. I found nothing so far.
>
> Perhaps start with the help
>
> https://help.libreoffice.org/latest/en-GB/text/sbasic/guide/translation.html
>
>
I didn't even think of that… I'll have a look there first, of course.


> Info from OpenOffice.org might be still valid:
>
> https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Dialog_Localization
>


> There had been some issues with localization of dialogs:
> According to https://bugs.documentfoundation.org/show_bug.cgi?id=130932
> you need at least LO version 6.4.
>

I currently run LibreOffice 6.4.3.3, so I'm fine, I guess.


>
> And this issue is not yet solved:
> https://bugs.documentfoundation.org/show_bug.cgi?id=100792
> It contains a test document.
>

I'll have a look at that too.

>
> Kind regards
> Regina
>
>
Thanks for replying! This should get me going.


Kind regards

Johnny Rosenberg


>
> --
> To unsubscribe e-mail to: [hidden email]
> Problems?
> https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
> List archive: https://listarchives.libreoffice.org/global/users/
> Privacy Policy: https://www.documentfoundation.org/privacy
>

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Johnny Rosenberg Johnny Rosenberg
Reply | Threaded
Open this post in threaded view
|

Re: Localized Basic macros

Den sön 10 maj 2020 kl 17:25 skrev Johnny Rosenberg <[hidden email]
>:

> Den sön 10 maj 2020 kl 15:29 skrev Regina Henschel <
> [hidden email]>:
>
>> Hi Johnny,
>>
>> Johnny Rosenberg schrieb am 10-May-20 um 14:35:
>> > Hi!
>> > I'm playing a little with macros (my level is probably one step or two
>> > above beginner) and making extensions out of them. I found a few
>> examples
>> > online and I got it to work.
>> >
>> > I don't know if I'm going to share anything in the future (because I
>> don't
>> > think my extensions will fulfil anyone else's needs than my own and they
>> > are probably poorly written anyway), but if I want to do that, there's a
>> > minor problem: My macros interact with the user (usually me) in Swedish,
>> > and I guess it would be a good idea to at least write an English version
>> > for sharing with others.
>> >
>> > However, it would be nice if the extension adapts to the user's locale
>> when
>> > installed (and falls back to English when the user's locale is not
>> > available, that is in most cases). Is that possible? A link to some
>> guide
>> > of some sort would be appreciated. I found nothing so far.
>>
>> Perhaps start with the help
>>
>> https://help.libreoffice.org/latest/en-GB/text/sbasic/guide/translation.html
>>
>>
> I didn't even think of that… I'll have a look there first, of course.
>

Seems like only custom dialogues can be translated, not text in general,
such as Print or MsgBox.
I could of course create some arrays with translations and use them
depending on which UI language is selected, but it doesn't seem to be
possible for a macro to detect that. I only found things like
ThisComponent.CharLocale.Language, but that seems to be more about the
selected language for characters, and it doesn't change when I just change
the UI language.


Kind regards

Johnny Rosenberg


>
>> Info from OpenOffice.org might be still valid:
>>
>> https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Dialog_Localization
>>
>
>
>> There had been some issues with localization of dialogs:
>> According to https://bugs.documentfoundation.org/show_bug.cgi?id=130932
>> you need at least LO version 6.4.
>>
>
> I currently run LibreOffice 6.4.3.3, so I'm fine, I guess.
>
>
>>
>> And this issue is not yet solved:
>> https://bugs.documentfoundation.org/show_bug.cgi?id=100792
>> It contains a test document.
>>
>
> I'll have a look at that too.
>
>>
>> Kind regards
>> Regina
>>
>>
> Thanks for replying! This should get me going.
>
>
> Kind regards
>
> Johnny Rosenberg
>
>
>>
>> --
>> To unsubscribe e-mail to: [hidden email]
>> Problems?
>> https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
>> List archive: https://listarchives.libreoffice.org/global/users/
>> Privacy Policy: https://www.documentfoundation.org/privacy
>>
>

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Jean-Francois Nifenecker Jean-Francois Nifenecker
Reply | Threaded
Open this post in threaded view
|

Re: Localized Basic macros

In reply to this post by Johnny Rosenberg
Hi Johnny,

Le 10/05/2020 à 14:35, Johnny Rosenberg a écrit :

> I'm playing a little with macros (my level is probably one step or two
> above beginner) and making extensions out of them. I found a few examples
> online and I got it to work.
>
> I don't know if I'm going to share anything in the future (because I don't
> think my extensions will fulfil anyone else's needs than my own and they
> are probably poorly written anyway), but if I want to do that, there's a
> minor problem: My macros interact with the user (usually me) in Swedish,
> and I guess it would be a good idea to at least write an English version
> for sharing with others.
>
> However, it would be nice if the extension adapts to the user's locale when
> installed (and falls back to English when the user's locale is not
> available, that is in most cases). Is that possible? A link to some guide
> of some sort would be appreciated. I found nothing so far.

IMO, as English is the lingua franca of IT, writing *any* code should
always be done in English (including comments). Using any other language
leads to what you're experiencing: no one will read the code, other than
a native.

As for user's interactions, yes, a translation into English could be of
use. I'm using po files with a Basic adapted gettext() function I had
written for that (well, it's a little more convoluted but you get the idea).

https://www.gnu.org/software/gettext/
https://www.gnu.org/software/gettext/manual/gettext.html

My 2 (euro)cents.

Best,
--
Jean-Francois Nifenecker, Bordeaux


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Johnny Rosenberg Johnny Rosenberg
Reply | Threaded
Open this post in threaded view
|

Re: Localized Basic macros

Den sön 10 maj 2020 kl 22:26 skrev jean-francois <
[hidden email]>:

> Hi Johnny,
>
> Le 10/05/2020 à 14:35, Johnny Rosenberg a écrit :
> > I'm playing a little with macros (my level is probably one step or two
> > above beginner) and making extensions out of them. I found a few examples
> > online and I got it to work.
> >
> > I don't know if I'm going to share anything in the future (because I
> don't
> > think my extensions will fulfil anyone else's needs than my own and they
> > are probably poorly written anyway), but if I want to do that, there's a
> > minor problem: My macros interact with the user (usually me) in Swedish,
> > and I guess it would be a good idea to at least write an English version
> > for sharing with others.
> >
> > However, it would be nice if the extension adapts to the user's locale
> when
> > installed (and falls back to English when the user's locale is not
> > available, that is in most cases). Is that possible? A link to some guide
> > of some sort would be appreciated. I found nothing so far.
>
> IMO, as English is the lingua franca of IT, writing *any* code should
> always be done in English (including comments). Using any other language
> leads to what you're experiencing: no one will read the code, other than
> a native.
>
> As for user's interactions, yes, a translation into English could be of
> use.


And that's all I want to do, a translation to the user's language. I never
intended to translate my comments or anything else to Swedish, except
things that directly communicates with the user, such as the MsgBox command
and the Print command.
I guess that if I can't have those translated, I could always replace them
with custom dialogues, but it seems a little bit like ”isn't there an
easier way?”.


Kind regards

Johnny Rosenberg



> I'm using po files with a Basic adapted gettext() function I had
> written for that (well, it's a little more convoluted but you get the
> idea).
>
> https://www.gnu.org/software/gettext/
> https://www.gnu.org/software/gettext/manual/gettext.html
>
> My 2 (euro)cents.
>
> Best,
> --
> Jean-Francois Nifenecker, Bordeaux
>
>
> --
> To unsubscribe e-mail to: [hidden email]
> Problems?
> https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
> List archive: https://listarchives.libreoffice.org/global/users/
> Privacy Policy: https://www.documentfoundation.org/privacy
>

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy