Lazarus messagebox: how to localize buttons - lazarus

I want to localize buttons of MesssageBox, MessageDlg, InputQuery, etc.
I see resourcestring exist for this in lclstrconsts: "OK"/"Cancel".... but I want to set button strings using asssignments.
How to do it?
I need it on Win32. I see that German/Rus OS shows En buttons.

That's how it is done for MessageDlg: http://delphi.xcjc.net/viewthread.php?tid=47562.
Variables with rs prefix should be defined.
Other components could be localized the same way.

There are several articles in the wiki about localization:
Translating/Internationalization/Localization
In short:
Set "Enable i18n" at the project options -> i18n, set PO Output Directory (locale for example)
Recompile project
Copy created yourproject.po file to yourproject.de.po, yourproject.it.po and so on for desired languages into the same directory.
Copy to locale directory of your project *.po files from lazarus/lcl/languages to translate LCL.
Add unit LCLTranslator to the uses clause of your main form.
Call SetDefaultLang('it'); somewhere to set desired translation (Italian in this example). Check is all Ok by inspecting GetDefaultLang function result.
Note that (3) is required.
You may find ready to use POs in other thirdparty libraries if any.

Related

Lazarus localization / multiple projects

I've got some Delphi experience and I'm trying to build a project with Lazarus, which is completely new for me.
I think, I've read all information available about Lazarus,Translating/Internationalization/Localization, but I was unable to find what I really want.
I've been working in a project with 3 or 4 EXEcutables, that share between them, the same database the same Interface (form inheritance), common utils, settings, and common and related strings.
I don't want to have 3 or 4 .po files with different names (one for each EXE) , with the same common strings shared between them.
Is there a solution for that?
probably force ONE "gobal.po" for all Apps? how?
do I have to create my own system to localize \ centralize all strings in ONE file?
any suggestions?
thanks for any help.
regards,
Use a shared language unit into which you put all the strings of all projects. Create a package into which you add this shared strings unit. Turn i18n on for this package. Compile the package and you'll get the shared po file in the languages folder.
For every project needing the resource strings, you must add this package as a requirement - the easiest way to do this is in the package editor and to select "Use" / "Add to project".
Don't turn on i18n for the projects because this would add the project po files to the languages folder.
In order to use translated strings in each project, add the unit "Translations" to uses and call
TranslateUnitResourceStrings(
StringsUnit,
Format('languages\%s.%s.po', [StringsUnit, ALang])
);
Here StringsUnit is the name of the shared unit with all the collected resource strings. ALang is the language symbol to be used, e.g. 'de' for German, 'fr' for French etc.
And now the hard part... Since i18n is off, the strings assigned to captions of components are not automatically put into the po file. So, you leave the component captions alone, create a resource string for each one (in the 'stringsunit', of course), and then, at runtime, assign the captions to the resourcestring. Maybe something like this:
procedure TForm1.FormCreate(Sender: TObject);
begin
SetCaptions;
end;
procedure TForm1.SetCaptions;
begin
Caption := RSTitleOfForm1; // resource string for form title
Label1.Caption := RSYDateLabel; // label caption showing "Date:"
// etc.
end;
If the user selects a new language, for example from a combobox with all the available translations, you must call TranslateUnitResourceStrings and then SetCaptions for each existing form (in case of dynamically created forms, SetCaptions will be called automatically since it is in the FormCreate event).

A new language, how to auto-complete in windows vim?

I'm using Gvim in windows.
Normally, when we type some character then press Ctrl-n, vim will show some tag, but those tags just includes words which have been pre-typed in the current file.
Now, I need it working in a new language, and show the tag which has been defined in other files.
So, I create a new \\.ctags for this new language, and generate tags file by exuberant-ctags.
I can choose a function in current file, then press Ctrl-] to jump to the function definition, but this function was define in the other files. It is working very well.
I don't know how to make it show the tags which are generated by ctags when I type some character.
Please help me. Thanks very much.
My English is poor, I hope you can understand what I said.
CTRL-N is just the default completion (which completes from a variety of sources, including the open buffers and also the tags database). There are many more specialized completions (all starting with CTRL-X), among them tags completion, triggered via CTRL-X CTRL-], see :help i_CTRL-X_CTRL-]. If you've correctly configured the 'tags' option (so your tags database is found) and tags jumps do work, just start using that.
Some languages / filetypes also define a language-specific completion (for language keywords etc.), usually via the 'omnifunc' option and triggered by CTRL-X CTRL-O. You could write such yourself, too.

Magento Translation

I have Magento 1.8.1.0. Recently I've installed Russian pack, the result wasn't appropriate enough, cause some phrases on frontend remained in English
I know there's handy way to translate Magento using cvs-files.
The question is where I can find proper cvs-file? Does installed theme concerns translation some how? I know I'm asking newbie questions, I've read several posts, but I haven't made up my mind how to translate Magento.
Many thanks in advance.
Hope you are doing well,
As i have gone through your question that you want to translate your websites front end in Russian if user has selected the language Russian.
For this you are required to work out the translate.csv files which will be available in your theme Package.
Example : app/design/frontend/default/SecuareWeb/locale/de_DE
In the locale folder you will find the folder for Russian language open that folder and you will find the file where you are required to add the required translation text in it.
How to add translation text in translate.csv file is given below.
Example:
"This is the demo of translation in Russian","Это демо-трансляции на русском языке"
And one thing i would like add is that make sure your front end .phtml files must contain the text in $this->__("Example");. If you have added all the text like this then only then it will allow you for translation other wise it will not translate a text.
Hope this might be use full to you !!!
Waiting for your valuable comments in regards to your Question !!!
There are different ways to achieve translation in Magento so you can find multiple directory containing static csv files and also a database table.
All the modes have same structure: key/value. For example: "String to translate","String translated".
Inline Translation (database table: core_translate):
following best practices in Magento, you should use inline-translation aka database saved translation in rare cases. It is harder to mantain and can be buggy. It has first precedence, so any translation you do via inline translation will override the other 'modes'.
Theme level Translation (file in app/design/frontend/your_package/your_theme/ru_RU/translate.csv):
you can place any string to be translated in the translate.csv. It has second precedence.
Locale translation (file in app/locale/ru_RU/Module_Name.csv):
the suggested way to do translation as it will keep translation separated by each module and is easier to maintain. For example: Mage_Catalog.csv etc.
Each module in Magento can specify its csv file containing translation and sometimes the same string has different modules trying to translate, so if your translation does not work check between multiple file by a quick editor search. It will be overridden by the two above modes.
Note:
Magento will load all the csv files and build up a giant tree and caches it. So before scratching your head because the string is not translated as you wished in the frontend:
1. clean the cache.
2. check for any same key string which comes after your translated string. For example: in the same csv Line 100 will override Line 1 if the key string are the same.
3. check for any same key string in the mode which has higher precedence. For example: inline translation will override any csv based translated string.
It may be easier for you to go to the admin backend System -> Configuration -> Developer and switch "Translate Inline" "Enabled for Frontend" to "Yes".
Then, refresh the frontend and you can change the translation directly at your web browser.
The translation is saved in the database table core_translate just for the case you want to do it in a test environment and copy the translation later on to the production.
Take care that without client restrictions (System -> Configuration -> Developer) everyone will see the translation options.
btw. You may need to clear the cache and refresh the webpage in order to see your changes.

Xcode 4: How can I reference project variables/macros in a file template?

Ok, so, I've got a relatively complex project template hierarchy that defines code style related macros and variables (curlies on same or new line, indentation, etc). My code style template will probably give more context
Works great when generating a project.
However, I'm not seeing a clear path to reusing these macros/variables when generating new files after the project has been built. Findings so far:
macros and variables defined at the project level are not substituted when referenced in a file template
popup option definitions in file templates do not seem to support complex definitions (e.g. defining a macro when the drop down is in a given state)
project variables do appear to become defaults for options of the same name in the file template wizard
file templates don't appear to be able to define other templates as ancestors
Any ideas?
Enter the following line:
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ "ORGANIZATIONNAME" = "Your Company Name" ; }'
into a Terminal window, replacing "Your Company Name" with whatever you choose.
You can also open the file at ~/Library/Preferences/com.apple.Xcode in "Property List Editor" and insert your company name as a string value for the key "ORGANIZATIONNAME" under the dictionary "PBXCustomTemplateMacroDefinitions". You may need to create "PBXCustomTemplateMacroDefinitions" at the top level if it doesn't already exist.

What are the best practices for building multi-lingual applications on win32?

I have to build a GUI application on Windows Mobile, and would like it to be able user to choose the language she wants, or application to choose the language automatically. I consider using multiple dlls containing just required resources.
1) What is the preferred (default?) way to get the application choose the proper resource language automatically, without user intervention? Any samples?
2) What are my options to allow user / application control what language should it display?
3) If possible, how do I create a dll that would contain multiple language resources and then dynamically choose the language?
For #1, you can use the GetSystemDefaultLangID function to get the language identifier for the machine.
For #2, you could list languages you support and when the user selects one, write the selection into a text file or registry (is there a registry on Windows Mobile?). On startup, use the function in #1 only if there is no selection in the file or registry.
For #3, the way we do it is to have one resource DLL per language, each of which contains the same resource IDs. Once you figure out the language, load the DLL for that language and the rest just works.
Re 1: The previous GetSystemDefuaultLangID suggestion is a good one.
Re 2: You can ask as a first step in your installation. Or you can package different installers for each language.
Re 3:
In theory the DLL method mentioned above sounds great, however in practice it didn't work very well at all for me personally.
A better method is to surround all of the strings in your program with either: Localize or NoLocalize.
MessageBox(Localize("Hello"), Localize("Title"), MB_OK);
RegOpenKey(NoLocalize("\\SOFTWARE\\RegKey"), ...);
Localize is just a function that converts your english text to a the selected language. NoLocalize does nothing.
You want to surround your strings with these values though because you can build a couple of useful scripts in your scripting language of choice.
1) A script that searches for all the Localize(" prefixes and outputs a .ini file with english=otherlangauge name value pairs. If the output .ini file already contains a mapping you don't add it again. You never re-create the ini file completely, your script just adds the missing ones each time you run your script.
2) A script that searches all the strings and makes sure they are surrounded by either Localize(" or NoLocalize(". If not it tells you which strings you still need to localize.
The reason #2 is important is because you need to make sure all of your strings are actually consciously marked as needing localization or not. Otherwise it is absolutely impossible to make sure you have proper localization.
The reason for #1 instead of loading from a DLL is because it takes no work to maintain this solution and you can add new strings that need to be translated on the fly.
You ship the ini files that are output with your program. You also give these ini files to your translators so they can convert the english=otherlanguage pairs. When they send it back to you, you simply replace your checked in .ini file with the one given by your translator. Running your script as mentioned in #1 will re-add any missing translations if any were done while the translator was translating.

Resources