I need to translate an application XUL by two versions English and French. Now all strings in interface on French. What are the tools and Libraries with I can translate the file .XUL or have you an others solutions?
XUL overlays add-ons usually localize with DTD or .properties files or both.
The old-but-still-accurate XUL Tutorial and the XUL School tutorial (add-ons) have some examples and descriptions.
Basically it boils down to:
Declaring one or more locales in your chrome.manifest. The browser will then make available the most appropriate locale automatically by the same URI prefix.
Using DTD in XUL (overlays, windows, dialogs).
Using stringbundles (aka. .properties) for everything else (or even instead of DTDs even for XUL).
Example
So for example you might have the following chrome.manifest declarations:
locale my-addon en-US locale/en-US/
locale my-addon en-GB locale/en-GB/
locale my-addon fr-FR locale/fr-FR/
You'd then add some.dtd to all locales (locale directories):
locale/en-US/some.dtd
<!ENTITY some.label "Hi">
locale/en-GB/some.dtd
<!ENTITY some.label "Hello">
locale/fr-FR/some.dtd
<!ENTITY some.label "Bonjour">
You can then access some.dtd by chrome://my-addon/locale/some.dtd and the application will automatically select whatever locale best corresponds to the browser and user preferences, e.g.
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://my-addon/locale/some.dtd">
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popup id="contentAreaContextMenu">
<menuitem label="&some.label;"/>
</popup>
</overlay>
Of course, this does not only work with .dtd, but with .properties and any other file. You can e.g. add a flag.png to all locales, and have the en-GB locale be the Star-Spangled Banner, the en-GB locale be the Union Jack, while having the fr-FR be Le Tricolore.
I demonstrated all of the above in a full-blown example add-on.
Add-on SDK
The Add-on SDK uses a similar but different localization system.
Testing
ProTip: You can test your add-on locales by changing the value of general.useragent.locale via about:config and restarting the browser. (There are also add-ons that to this for you). This will even work if the browser is e.g. only English and you switch to e.g. French fr-FR/fr. Then only the add-ons (incl. your add-on ;) that have a French locale will display french strings while the others will fall back to en-US or whatever they support.
Related
So I understand how Multilingual App Toolkit 4.0 works and it works great for my Xamarin.Android project. The default language is English, and with MAT we've translated it to Dutch and German.
Then comes the translator along and asks about how to make changes to the English texts, which is my source texts and the basis of all translations. The source texts (English) are in a file Resources\values\Strings.xml. Alter a string there, would invalidate all translations (Dutch and German).
Besides invalidation, I can't send my translator the normal .xlf file, because all source texts are in the Strings.xml file.
So my question is, how can my translator alter the source language texts in the most easy way (preferably with an .xlf file)?
The short answer is that you can't. The design of the Multilingual App Toolkit focused on providing easy support for translation into other languages. The concept of providing source content editing was not considered.
That said, as a workaround you could add another variant of English. For Android apps, the default is English Neutral (en), so adding en-US or en-UK would create the XLIFF file that your translator / proofer could edit using the same tooling (e.g.: Multilingual Editor) to provide source content proofing. If using the same translator for proofing and translating, they could apply the translation based on the update English string to the Dutch and German files.
When you receive the XLF files back ensure all the resource in the proofing English XLF (e.g.: en-US) are marked as need review, translated or final (basically anything except 'New'). The reason is that the Multilingual App Toolkit does not include untranslated resource in the generated target resource file. (The reason is for language fallback purposes in Windows apps).
Now you can import the proofed English file with the other XLF file and build. Copy the entire contents from the proofed English resource file(s) overtop the original source files (recommend Comparing first). When you next build, you will receive warnings that the source resources have changed after the translation, but you can just review and clear those warning in the editor, or clear them globally within the Visual Studio IDE.
I have created a Firefox Add-on using jpm and I have added a number of localization files such as:
locale/da.properties
locale/en-GB.properties
locale/en-US.properties
locale/fi.properties
And so on...
In my HTML files I use attributes to set these values, for example: data-l10n-id="ext_panel_heading_text".
I know the translations are working, because changes I make to values in en-GB.properties are reflected in my add-ons HTML page.
I've tried navigating to Options > Content > Choose... (under languages), removing English and adding another language (such as Finnish), however it doesn't seem to have an affect on the .properties file loaded by my extension. I also tried restarting Firefox after changing the language.
My question is: How do I test the different languages?
The language of Firefox is dependent on the activated language pack, or for Windows and Mac I believe it is hard coded into the build.
Language packs are available from https://addons.mozilla.org/en-US/firefox/language-tools/
The only way I know is to change general.useragent.locale to the locale you want to use (en-GB, da, en-US, fi) in about:configand then restarting your browser: that way your add-on should show localized texts.
As an alternative, you can use Quick Locale Switcher, which does the same but it's a little more friendly.
I've added english language to my app written originally in polish, set the default language to en-us but for some reason people from non-english speaking countries still get the polish translation, any ideas?
You have to modify the project file manually:
<PropertyGroup>
<SupportedCultures>en;pl</SupportedCultures>
You don't have to add your default language to SupportedCultures
I just implemented the internationalization (i18n) feature of google chrome in my extension. I have languages de and en. I named de as default in the manifest file:
"default_locale": "de"
No I want to test if en works but
"default_locale": "en"
has no effect on the language, it stays german. Any ideas?
It is still German because your browser locale is German. Internalization API has detailed instructions on how to switch your locale for testing (scroll to the middle of the page).
Is it possible to create Firewox extension that will not shown in Extensions List? And so cannot be deinstalled manually?
To Hide an extensions/addons in the list of extension about:addons simply follow these few simple steps:
(1) Create an a zipfile myextenios.zip (firefox extension are actually zip files) having this structure:
myextension.zip
|
|--chrome.manifest
|--install.rdf
|--[content]
|--hideExtensions.css
(2) The chrome.manifest should have this content:
content myextension content/
style chrome://mozapps/content/extensions/extensions.xul chrome://myextension/content/hideExtensions.css
style about:addons chrome://myextension/content/hideExtensions.css
(3) The install.rdf should have this content:
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>myextension#yoursite.de</em:id>
<em:name>myextension</em:name>
<em:description>This addon hides addons entries in about:addons</em:description>
<em:optionsURL></em:optionsURL>
<em:iconURL></em:iconURL>
<em:version>1.0</em:version>
<em:creator>your name</em:creator>
<em:homepageURL>http://www.yourside.de</em:homepageURL>
<em:type>2</em:type>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0</em:minVersion>
<em:maxVersion>14.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
(4) Lastly the file hideExtensions.css has to have the following content:
(note: of course you might wanna adjust the name of the extension you want to hide)
.addon[name="1. Name of addon to hide"],
.addon[name="2. Name of addon to hide"],
.addon[name="3. Name of addon to hide"],
.addon[name="myextension"]
{
display:none;
}
(5) Rename the myextension.zip to myextension.xpi so that it recognized as a extension + install it by dragging the file into Firefox browser window.
Conclusion:
Most of the steps baove are equal to those of the creation of any other firefox extension. Therefore anybody with the knowledge to create an firefox addon/extension can also cause this extension not to show up in the addon list you see when you enter about:addons. Consequently if you have just one malicious firefox extension (virus) then you cannot trust Firefox as much to even see this virus-extension in the list.
See this mozillazine entry and this forum entry. These extensions are somehow installed via the registry and supposed to be malicious - so there's no use for this except if you want to be on some malware blacklist.
For private use or administration use like MSalters suggested in his comment, "hidden" (for some users) extensions could be useful, but this should be implemented by Mozilla first.