Localization of macros

Hi all,
I often need to have text strings other that dialog labels. This can be
error messages, status line messages and msgbox() text.

Does anyone here has experience with developing localizable macros?

It is possible to localize dialogs, the but is there a some kind of best
practice method to access these strings from a Basic macro?

I have found a way to do it, but if there is an official way of doing it, I
would like to hear about it.

Cheers,
Leif Lodahl

Other than reviewing best practices for the content and display of error messages from a macro I would check Andrew Piontyak's Basic guide for OO/LO. I am not sure of the links.

Probably the best advise is to think of the user, the desired (or required) response from them, and being clear but concise about the problem. If possible indicate to the user what they can do to possibly fix the problem. Many error messages are extremely cryptic to the users.

Hi :slight_smile:
It might be worth asking the Devs list about this perhaps? I suspect it's slightly "over the heads" of most of us. There are a few devs or almost devs here but not many. I would guess that the 'local' teams might have a similar issue.

It is usually good to ask any questions here first and then maybe we can either answer directly or point people to other resources where they might get a better answer.
Regards from
Tom :slight_smile:

Hi :slight_smile:
Dohhh!! I should have known that and given the link as i created that page to try to make things easier to find!! Sorry chaps (and ladies), here's a link
http://wiki.documentfoundation.org/Documentation/Publications#Programmers
Regards from
Tom :slight_smile:

Hi Leif,

Leif Lodahl wrote (29-11-11 09:37)

I often need to have text strings other that dialog labels. This can be
error messages, status line messages and msgbox() text.

Does anyone here has experience with developing localizable macros?

I have somthing simple done in my extension
http://extensions.libreoffice.org/extension-center/ct2n-convert-text-to-number-and-dates/releases/1.4.0/converttexttonumber-1.4.0.oxt/view

Just a function with all strings. YOu could have thought about that yourself :wink:

But IIRC, there was some way too, to use the xml file that contains the translated strings for the dialogs..

Cheers,

From what I have seen on the dev list, unless you are actively fixing bugs (or similar), don't bother them. I don't mean that they are evil incarnate, just that the list claimed to be for that and only for that and they will either mention that to you or simply ignore your request.

That said, perhaps there is another dev mailing list of which I am not aware, but would like to be aware. Please enlighten me if this is so.

I have only done this in extensions. I can send you an example if you desire..... But... I need to take a dog out to go to the bathroom.

Hi :slight_smile:
Oh :frowning: That is disappointing. I hoped they would enjoy an occasional odd question :frowning:
Apols and regards from
Tom :slight_smile:

I agree. On the other hand, they are very helpful for those contributing to LO. Sufficiently so, that I have considered contributing just because it would be fun :slight_smile:

Hi :slight_smile:
You do contribute tons already.  Perhaps not as a dev but in here and in the documentation team which should both be counted as valid contributions to the project imo.  It's not just the devs that are building something here. 
Regards from
Tom :slight_smile:

Thanks Andrew,
Please send me your ideas and examples.

My idea is also to use it in an extension.

I have upload my ides of an extension here
http://blog.magenta-aps.dk/wp-content/uploads/2011/11/Review.oxt .

The extension creates a new toolbar called Review. The right most icon
starts a macro with a dialog that is localized (so far only English and
Danish is included). All localization stuff is in the module "Localization".

Problems so faris:

   - When I read the DialogStrings_xx_YY.properties i have some problems
   with encoding. Only files created on the same platform shows right (Danish
   language consist of some non-ascii characters æ, ø and å.
   Currently this reads with wrong encoding on Windows (use Danish version
   to see the problem).
   How can that be solved?
   - Effectiveness. I'm not sure this is the most effective way and I'm
   affraid that with many strings it will run slow. I haven't tried with more
   than these very few strings.

Missing work to be done (not problems)

   - Error handling
   - Better way to load only relevant strings (only partly implemented so
   far)
   - Default language should be from DialogString_xx_YY.default and not
   hardcoded
   - Script to generate Addons.xcu and /Office/UI/XYZWindowState.xcu

Feel free to tell me what you think of my solution.

Cheers,
Leif Lodahl
The Danish Team

That was my impression too. I'm looking forward to the forum will be set up.

Cheers,
Leif Lodahl
The Danish Team

Cheers to the dog :slight_smile:

/Leif

Thanks Andrew,
Please send me your ideas and examples.

I sent you a full copy of the source used to create an extension, complete with the extension as well. Notice all the bits and pieces. To build it, extract the TAR file into a directory and then open the ODT file. The ODT file contains things to drive the creation. Also, look in Module1 of the Standard module.

This contains numerous things including menus for different locales. There is also a dialog, and you can see bits and pieces of files used for the localization in the tar file.

When you are ready to build, simply run module1 from the Standard library and it will create the OXT file.

My idea is also to use it in an extension.

I have upload my ides of an extension here
http://blog.magenta-aps.dk/wp-content/uploads/2011/11/Review.oxt .

The extension creates a new toolbar called Review. The right most icon
starts a macro with a dialog that is localized (so far only English and
Danish is included). All localization stuff is in the module "Localization".

Problems so faris:

    - When I read the DialogStrings_xx_YY.properties i have some problems
    with encoding. Only files created on the same platform shows right (Danish
    language consist of some non-ascii characters æ, ø and å.
    Currently this reads with wrong encoding on Windows (use Danish version
    to see the problem).
    How can that be solved?
    - Effectiveness. I'm not sure this is the most effective way and I'm
    affraid that with many strings it will run slow. I haven't tried with more
    than these very few strings.

Ahhh, I can perhaps take a look, but it is already 3:00 AM and I must be up early for work.

Hi Andrew,
I can see that you have another approach to the problem so far. My idea has been to use the already existing localization files to also localize other things than dialogs.

More comments inline to spare you a lot of time (I solved the most important problem).

Thanks Andrew,
Please send me your ideas and examples.

I sent you a full copy of the source used to create an extension,...

Wow.
This is certainly a bunch of gold. I will use this to compile the final extension - I'm sure.

For others who might be interested: Is this public available somewhere? I can recommend to every macro programmer to have a look.

My idea is also to use it in an extension.

Problems so faris:

    - When I read the DialogStrings_xx_YY.properties ... <- problem solved :wink:
    - Effectiveness. I'm not sure this is the most effective way and I'm
    affraid that with many strings it will run slow. I haven't tried with more
    than these very few strings.

Ahhh, I can perhaps take a look, but it is already 3:00 AM and I must be up early for work.

Hey its no hurry.
in the meantime I asked a colleague for help and we found a solution for the UTF8 problem. New version here:
http://blog.magenta-aps.dk/wp-content/uploads/2011/12/Review.oxt

But I still would like your opinion.

For the record: If anyone can use it, its free software (LGPL/GPL or something) :wink:

I posted the entire thing here:

http://extensions.libreoffice.org/extension-center/code-colorizer-formatter/