How to implement a language / culture (that is not yet supported) in ActiveReports 11? - internationalization

We already have a vast group of .rpx files that contain report definitions in german. We have used scripting to translate some of the text to romansh (official swiss language used by <1% of population), yet it has been requested.
The vision now is to create reports in french and maybe italian as well. Yet we are well aware that the current scripting approach like:
if (txtSprache.Text == "RM")
{
lblAbonnentenNr.Text = "Abo-nr.:";
lblAbrechnungVon.Text = "Quen dils:";
lblBis.Text = " -";
lblZahlbarBis.Text = "Pagabel tochen:";
lblObjekt.Text = "Object:";
lblRechnungsNr.Text = "Nr. dil quen:";
lblRechnungsdatum.Text = "Datum da quen:";
lblERechnungsID.Text = "ID";
lblAbonnent.Text = "Abonnent";
}
Is not well suited for that. I have been asked to create options for I18n support. Quoted from the AR11 documentation:
To localize a Report at design time
1. Click the gray area around the design surface to select the Report in the Properties window.
2. In the Properties window, drop down the Culture or Language property and select the culture that you want to apply to the report.
The old default was: (default, inherit), I know changed that to German (Switzerland). I couldn't find any difference, no new stuff under C:\Program Files (x86)\GrapeCity\ActiveReports 11\Localization, nor elsewhere in the xml.
How do I add a new language sheet / values for the current report and it's labels?
How do I add a culture that does not exist yet? (In worst case I'd use any local and use it as romansh, since only german, italian, french and unlikely english could be used)

The Language property, mentioned in the documentation, works for the code-based templates only. When you set the new language by this property VSID creates the additional resource file, e.g. myreport.jp-JP.resx.
In such case, the compiled report will upload the needed resources according to CurrentThread.CurrentUICulture value. It does not work for RPX(xml-based) templates.
So if you want to use this functionality, you need to convert xml-based to code-based templates.
The Culture property helps only to specify a locale for OutputFormat feature(e.g. conversion to currency).
For RPX templates localization, I think you could combine the external localization resource files with the current scripting approach, I mean the loading of the resource file in script and update the report items.
Thanks,

Related

How to enable Latin names for places in some places instead of local ones in Carto Services?

Some places on the map is labeled with Cyrillic names, but I need only English/Latin names of places on the map, however sometimes there are only local names. How can I implement this?
P.S.: I have spotted this issue on Belorussian and partly on Russian places.
Screenshot
About languages in general: after all, it depends on which languages specific placename is tagged with. OpenStreetMap has always "local" variant in local primary language, and CARTO Mobile SDK uses this by default, but the data has also other languages, so you can control it as following.
CartoVectorTileLayer (both CartoOnlineVectorTileLayer and CartoOfflineVectorTileLayer are subclasses of it) has method setLanguage(String) to select language, so e.g.:
layer.setLanguage("en");
will give you English language maps.
In SDK 4.0.2 SDK and nutiteq.osm tile source you can use following languages: local/default, en, es, de, fr, it, ru, zh (Chinese), tr (Turkish) and et (Estonian) as language
With latest CARTO SDK 4.1.0 and new carto.streets source you can use any OSM language. I would suggest to configure map based on device language settings, with something like:
// Android
layer.setLanguage(Locale.getDefault().getLanguage());
// iOs / Xamarin
layer.Language = Foundation.NSLocale.PreferredLanguages[0].Substring(0, 2);
What if specific name is not available in given language? Then the MapView will fallback to 'local' language by default, the map will not be empty. But if the 'local' language is still unreadable, so I'd prefer latin alphabet names? In SDK 4.1.0 you can configure primary and secondary fallback languages, e.g. you set primary language to 'de' for Germans, then to avoid strange alphabets (say Hebrew, Greek, most of Asia) set 'en' as primary fallback; then local is used only if both your primary and English names are missing:
layer.FallbackLanguage = "en";
Now I know you want automatically transliterated / Romanizied names, so even if source data from OpenStreetMap has e.g. names in Cyrillic only (Russia, Belorussia etc), then it would show them in Latin chars. It is not exactly same as translation, e.g. Moscow would become Moskva with Romanization, but can be helpful for many cases, actually with all none-Latin scripts, especially from Asia (Chinese etc). The problem here is that many languages, including Russian have many competing Romanization rules, so even if we would want to, then we could not do it in general SDK map rendering level. Our CARTO SDK may provide API for app to apply your preferred translation table, but we do not have this anyway. The SDK is open source and you are welcome to provide patch for the feature. I added issue ih the project for this: https://github.com/CartoDB/mobile-sdk/issues/147

Firefox string resources: How to get localized friendly languages names?

I'm developing a Firefox extension that involves dictionaries in various languages and dialects. I want to display a dialog to the user to select spell checking dictionaries for the available languages.
It will be tedious for the user to select from values like en-US, ar-EG, en-GB, etc., so, I want to display the localized language names like what Firefox does in this screenshot
This is the dictionary selection menu on my Arabic Firefox displaying the names of the two languages en-US and ar.
How to do such thing?
Here is what I did to find and use these strings:
1- I downloaded the whole Firefox source code and extracted it.
2- I searched the source files for the name "New Zealand". This unique country name should exist only in the file I'm looking for. Rather than using general terms like English, United States, Arabic, etc.
3- The search led me to two interesting files: regionNames.properties and languageNames.properties. The first has the names of all countries and the other has the names of all languages. Firefox should be using the two sets of strings to display dictionary names.
4- I found that the two files can be fetched from the URLs chrome://global/locale/languageNames.properties and chrome://global/locale/regionNames.properties, so, I used the string bundle service and the string bundle objects to load and use the resources.
Here's a code sample:
On the top of my main.js file:
const {Cc, Ci, Cu} = require("chrome"),
stringBundles = Cc["#mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
Then I have this piece of code in another method:
let languagesNamesBundle = stringBundles.createBundle("chrome://global/locale/languageNames.properties"),
countriesNames = stringBundles.createBundle("chrome://global/locale/regionNames.properties");
console.log(languagesNamesBundle.GetStringFromName("ar")); // العربية Arabic
console.log(languagesNamesBundle.GetStringFromName("af")); // الأفريكانية Afrikaans
console.log(countriesNames.GetStringFromName("fj")); // فيجي Fiji
console.log(countriesNames.GetStringFromName("cr")); // كوستا ريكا Costa Rica
And this is what I wanted. Now I can compose dictionary names from languages and countries names.
I'll update the answer to add the path of the project repository after I publish the final result.
This is very easily doable. I have some very basic templates for localization here:
https://github.com/Noitidart/l10n/tree/xhtml-xul
https://github.com/Noitidart/l10n/tree/properties
properties files are for within privelaged js file localiztion. and .dtd is used for xul/xhtml/and inline javascript.

WinRT Localization - Multiple Translations per Language

I am building a Windows Store application in XAML/C# for a Windows 8.1 Professional environment.
My project has a requirement that I must support multiple languages in addition to multiple translations for any given language. For example, I may have a label that would be displayed in English or French, but in English it may need to display the word "Title" or the word "Heading" depending on the customer's preferences.
My issue is that I cannot figure out a way to package and switch between multiple resource dictionaries for the same language while still using the built-in localization functionality provided by XAML for WinRT (i.e. using the Uid property on my controls to bind them to a resource dictionary).
I've noticed two functions, ResourceManager.LoadPriFiles and ResourceManager.UnloadPriFiles, that I thought might allow me to swap out resource dictionaries at runtime, but I can't figure out how to get the PRI files to be package outside of the application's main resource map to allow the loading and unloading.
I've also considered creating a custom data binding or converter that I could use to bind the controls' text manually, but that would cost me the ability to see labels at design time in Blend as well as sacrificing the convenience of the built-in localization capabilities.
Another option was to compile a separate instance of the application for each of the custom translations the customer might require, but obviously that's not a very maintainable way of solving the issue...
Finally, I had considered repurposing something like the homeregion qualifier of the ResourceContext to solve the issue; however, that seems very limiting as there are already pre-established homeregions that I would have to choose from. Repurposing fields seems like a bad idea in general.
You can use several resources files and use the PrimaryLanguageOverride property to select a different language than the default one. This will allow you to change the current resources set without doing anything specific.
You can use a structure like this one for your resources:
Strings
+- en-US
+-Resources.resw
+- fr-FR
+-Resources.resw
+- fr-other
+-Resources.resw
Then in you code, you will just have to call any of the following lines :
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fr-other";
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fr-FR";
You application will now use the "fr-other" language. You can use up to 8 characters in the second part of the language tag.

Is it possible to use the single resource file for all english cultures?

So the question is can I point out that my application supports en-US, en-GB and use for all of them the single resource file?
The intention is that I want my application to be available for all english-speaking countries. But it's meaningless to have different translations, because there are no specific translations.
Does it have a sense considering the mentioned intention to point out all those specific cultures in a manifest?
Yes - just use one English file and make it as default culture. This way even when en-GB is selected, for example, the app will fallback to en-US :)
As for date formatting - just be sure to use CurrentCulture - it gets formatting from the Regional and Number settings (and not CurrentUICulture which is for language needs only). This way people with, say, en-US UI language and Number formatting set to de-DE will still see the app in English but have number formatting as German.
There is a common confusion between CurrentCulture and CurrentUICulture and that Language equals formatting. That's why I see many 12-hour formats throughout Windows Phone/Store apps that simply ignore my Regional settings. A must-read regarding confusion about UI and Number formatting: http://forums.asp.net/post/1080435.aspx

How to detect the Language set in the Windows phone

I need to detect the language of the phone so that I can display the message accordingly. If it is english , then display english. Say, I target a few countries such as China,japan, Korea. How do I do it? here my incomplete code to show what I mean:
tring StrLanSetOnClient;
string strLanEng= "english Msg";
string strLanChn=" Msg in chinese character";
string strLanJpn= "Msg in Japanese character";
string strLanKor= "Msg in Korean character" ;
strLanSetOnClient = CultureInfo..........
If( strLanSetOnClient == "English")
{
txtBlkLan.Text = strLanEng;
}
elseif ( strLanSetOnClient == "Chinese")
{
txtBlkLan.Text = strLanChn
}
....
Thanks
--- Updated Questions:
1) Where should I detect the language? In App.xaml?
2) How all pages can refer to this global variable name?
3) Which is the best practise to detect ? use CultureInfo or thread.currentThread
Thanks
&#lt;?xml version="1.0" encoding="utf-8"?&#gt;
&#lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&#gt;
&#lt;ProjectExtensions&#gt;
&#lt;VisualStudio &#gt;
&#lt;FlavorProperties GUID="{C089C8C0-30E0-4E22-80C0-CE093F11xxxx}"&#gt;
&#lt;SilverlightMobileCSProjectFlavor&#gt;
&#lt;FullDeploy &#gt; True &#lt;/FullDeploy&#gt;
&#lt;/SilverlightMobileCSProjectFlavor&#gt;
&#lt;/FlavorProperties&#gt;
&#lt;/VisualStudio&#gt;
&#lt;/ProjectExtensions&#gt;
&#lt;/Project&#gt;
This is the vanila csproj file of my Wp7 App. There is no SupportCulture tags in it. So, I have to add this tag in it right when I open it with notepad? When I downloaded your sample app, I open the csproj file with notepad, i dont see this tag either? Thanks
The way you're trying to do localization is to get very complicated, have lots of duplication and be difficult to change in the future.
There is a built in way of supporting multiple languages/cultures/etc. See http://msdn.microsoft.com/en-us/library/ff637522(v=vs.92).aspx
I wrote a blog on this very subject just the other day. It describes how to localize from start to finish, and it is located at www.hopnet.mobi, click Blogs.
Once you get the hang of it, localization really isn't difficult at all. I've localized one app, and I'm waiting on a friend to validate my translations. While she's doing that, I'm localizing the other apps. More languages means wider distribution, which means more money. You're doing the right thing!
Use CurrentCulture which is in your System.Globalization namespace. It has properties like Name, EnglishName, DisplayName and NativeName so you pick which one suits you most.
EDIT: Detecting the language will depend on whether you want to allow users to change the language or not. If not then detect it in App.xaml.cs and store the information in an IsolatedStorage object so that you can share it among different pages. This way you can avoid detecting the language settings later and just rely on the saved settings. As for the best practice I stick to CultureInfo. I never tried going directly through Thread.CurrentThread.

Resources