CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: localization

Working with resx files in Visual Studio

Today I found a nice Visual Studio Extension for working with localization and resx files: Resx Resource Manager. This extension provides an additional view in your project and scans all the resx files. I would recommend it to all projects where you have to translate your interface. Here is how it looks in my project:

resx-001

It can also assist with some machine translation from Bing and MyMemory:

resx-002

Another good thing is the Export and Import to and from Excel. Wonderful if you need help from Non-developers.

resx-003

On Windows keyboard layouts for minority languages in Russia

keyboard-bak-tat-sak

I can’t write in Chuvash in Windows 8 (and all the previous Windows releases). Chuvash is a minority language in Russian Federation. In this blog post I want to summarize the status of the keyboard layout support of the minority languages of Russia and find a way to improve this situation.

Languages and Microsoft

There are thousands of languages. Of course it is hard to support them all. As per 2012-02-21 Windows 8 supports 109 (!) languages. In december 2012 the support for Cheerokee language was added.

Display language, locale and keyboard layout

In Windows 8, when you go to Language preferences – Add a language, you’ll get “a language”. Behind this general word there are three parts which have to be distinguished in this post:

  • Display language (labels, messages and other user interface in the particular language)
  • Locale (a set of preferences for a particular language and region/country like currency, point or comma as a decimal delimiter, ltr vs rtl, encoding and much more)
  • Keyboard layout (just an arrangement of keys, their placement, can be specific for a language or country, can have different systems like Dvorak)

This blog post is about the keyboard layouts, the easiest part of the “language” support in an operating system.

Russian Federation minorities

There are 160 ethnic groups in Russia speaking over 100 minority languages. The most of ethnic groups ar so called stateless nations meaning there is no main country for this nation (e.g. Sami people in Sweden, but not Germans in the USA).

In Russia there are 21 republics which have their own official languages alongside Russian and their purpose is to be home for ethnic groups. I’ll focus mostly on the official languages in these republics in this blog post, but it would be interesting to investigate smaller languages as well.

Allmost all of the minority languages of stateless nations use the Cyrillic alphabet (often with additional letters). So it makes it pretty simple to see how many languages are supported in Windows 8. Just Go to the Language preferences -> Add a language and group them by writing system. See the screenshot above. There are only three minority keyboard layouts which are supported:

  • Bashkir (1,45 millions speakers)
  • Sakha (Yakut, 360 native speakers)
  • Tatar (4,3 millions speakers)

The funny thing is that all the three are Turkic languages.
There are two additional language keyboard layouts which are implicitly supported:

These two languages (which are co-official languages in the republic of Mordovia) don’t use any additional letters. That’s it. So they can write using only the standard Russian keyboard layout.

Keyboard layouts in Linux

Just a little comparison. In Linux distributions there are more minority languages from Russian Federation represented. The supported ones can be found in the /usr/share/X11/xkb/symbols/ru file:

  • Tatar / tt
  • Ossetian / os
  • Chuvash / cv
  • Udmurt / udm
  • Komi / kom
  • Sakha (Yakut) / sah
  • Kalmyk / xal
  • Bashkir / bak
  • Mari / chm

All these keyboard layouts were added by the community. I personally sent the Chuvash and Kalmyk fragments of that file to Sergey Udaltsov who created patch files and pushed it to freedesktop.

keyboard-xal

Windows 8 keyboard layouts and Touch mode

When I tried these three supported minority language keyboard layouts of Russia in touch mode, only one worked! It was the Tatar keyboard layout.
tatar-keyboard-layout-in-touch

The tatars can type all their additional letters in touch mode as well.

Bashkir and Sakha keyboard layouts use the row above qwerty: 12345… Here is the preview for the classic Sakha keyboard layout:

sakha-preview

And what about the virtual touch keyboard layout for Sakha language?

sakha-touch

As you can see there are no keys for the additional letters for Sakha language (ҕ ҥ ө һ).

Summary

Many minority languages of Russian Federation (the most of them already endangered) miss the native keyboard layout support in Microsoft Windows 8 and Windows 7. Windows is a prevalent operating system in Russia. The support for minority language keyboard layout would help people to use their languages and give more chances for languages to survive. For now there are only 3 languages (besides Russian and implicitly some others like Moksha and Erzya) which are supported in Windows 8 with a physical keyboard: Tatar, Bashkir and Sakha. And only one of them (!) works even in touch mode: Tatar.

The purpose of this post is only to identify the status for Russian Federation minority language keyboard layout support in Windows 8. Microsoft Local Language Program (LLP) seems very promising. I hope we will see more languages of Russia and other countries available in “Add language” menu in Microsoft Windows 8.

Long tap and additional letters in Windows 8 (update 2013-03-16)

After I wrote this post I discovered some additional letters available when you long-tap the buttons on the virtual keyboard. Here is an excerpt from the Microsoft Blog about the “press-and-hold”-letters:

There is an interesting counter example in press-and-hold behavior. On a physical keyboard, when you press and hold a character, it repeats. On our touch keyboard when you press and hold, we show alternate characters or symbols. This is something a touch keyboard can do well and a physical keyboard can’t. If you don’t know the specific key combination to show ñ or é or š, for example, it’s painful to type on a physical keyboard. It’s easy to find on the touch keyboard. Practically no one has complained about this departure from convention. We built on it, in fact. You might discover that you can simply swipe from a key in the direction of the secondary key, and that character will be entered, without an explicit selection from the menu. So if you use accented characters a lot, you can get pretty fast with this.

I appreciate this. Here come all the letters I found in the Russian keyboard layout:

Flyout letters Main letter Additional letters
long-tap-u у ү   ұ
long-tap-k к ҡ   қ
long-tap-n н ң   ҥ
long-tap-g г ғ   ҕ
long-tap-z з ҙ
long-tap-h х һ
long-tap-o о ө
long-tap-e э ә
long-tap-s с ҫ
long-tap-i и і

Here is the full list of the Cyrillic additional letters:

ү Cyrillic Ue Bashkir, Tatar, Kazakh, Buryat, Kalmyk, Kyrgyz, Mongolian
ұ Straight U with stroke Kazakh
ҡ Bashkir Qa Bashkir
қ Ka with descender Kazakh, Uyghur, Uzbek, Tajik, Abkhaz
ң En with descender Bashkir, Tatar, Kazakh, Dungan, Kalmyk, Khakas, Kyrgyz , Turkmen, Tuvan, Uyghur
ҥ En-ghe (Cyrillic) Sakha, Meadow Mari, Altai, Aleut
ғ Ge with stroke Bashkir, Kazakh, Uzbek, Tofa, Tajik
ҕ Ge with middle hook Sakha, Abkhaz
ҙ Ze with descender Bashkir
һ Shha Bashkir, Sakha, Tatar, Kazakh Buryat Kalmyk Kildin Sami
ө Barred O (Oe) Bashkir, Sakha, Kazakh, Buryat, Kalmyk, Kyrgyz, Mongolian
ә Cyrillic Schwa Bashkir, Tatar, Kazakh, Abkhaz, Dungan, Itelmen, Kalmyk, Kurdish
ҫ Cyrillic The Bashkir, Chuvash
і Dotted i Kazakh, Ukrainian, Belarusian, Khakas, Komi, Rusyn

Those are missing: ӑ ӳ

ӗ E breve Chuvash
ӑ A breve Chuvash
ӳ U with double acute Chuvash
ӝ Zhe with diaeresis Udmurt
ӟ Ze with diaeresis Udmurt
ӥ I with diaeresis Udmurt
ӧ O with diaeresis Udmurt, Meadow Mari, Hill Mari
ӵ Che with diaeresis Udmurt
ӓ A with diaeresis Hill Mari
ӱ U with diaeresis Meadow Mari, Hill Mari
ӹ Yery with diaeresis Hill Mari

Here we have four fully functional language keyboard layouts if you are okay with long-tapping:

Bashkir ғ ҡ ҙ ҫ ң һ ә ө ү
Sakha ҕ ҥ ө һ ү
Tuvan ң ү ө
Buryat ө ү һ

Bashkir and Sakha, I suppose, were considered whilst designing the keyboard layout, and Tuvan and Buryat language letters only happen to be within the Bashkir and Sakha letters range.

Tatar letters aren’t complete in the standard Russian keyboard layout, the reason for that must be, as I mentioned above, the full functional virtual keyboard for Tatar (where is no need for long-tapping).

There is another language which contains all the letters through long-tapping. Kazakh is absolutely a minority language of Russia, but it doesn’t represent a stateless nation.

Kazakh ғ ә қ ң ө ү ұ і һ

Long-tapping technique could be a solution for many minority languages of Russia:

Language Existing letters To be added
Chuvash ҫ ӗ ӑ ӳ
Udmurt ӝ ӟ ӥ ӧ ӵ
Meadow Mari ҥ ö ӱ
Hill Mari ä ö ӱ ӹ
Komi і ö
Altay ҥ ј ӧ ӱ

JavaScript Localization in SharePoint

Yesterday Waldek Mastykarz published a cool post: Globalizing JavaScript in SharePoint 2013. This is a very cool technique to localize your client code in javascript and reuse your resx files in Server Side and Client Side. This is actually not new for SharePoint 2013 despite it has become more needed with the huge client focus in the new SharePoint. I have used this in SharePoint 2010 for a long time. In my blog post: ScriptResx.ashx in SharePoint I told about that technique. What I didn’t know that you can define your javascript namespace directly in the resx file. Waldek wrote in his comment that SP.Publishing.Resources.en-US.resx automatically are SP.Publishing.Resources in javascript. That was not the case for my own localization files. A simple look at SP.Publishing.Resources.en-US.resx helped:

scriptresx

  <!-- 
    Whether this .resx could be read by scriptResx.ashx handler. Only a file
    marked with scriptResx:true could be returned to client.
  -->
  <resheader name="scriptResx">
    <value>true</value>
  </resheader>
  <!-- the full name of the JavaScript class.  -->
  <resheader name="classFullName">
    <value>SP.Publishing.Resources</value>
  </resheader>

This results in:

_EnsureJSNamespace('SP.Publishing');

So what we have to do for our custom resx file is to add classFullName resheader:

  <resheader name="classFullName">
    <value>Takana.Res</value>
  </resheader>

Chuvash localization of moment.js

For three months ago I added Chuvash localization of moment.js. For 16 days ago moment.js 1.7.0 was officially released which included the Chuvash translation.

Wait a sec… What is moment.js?

moment.js is the best datetime tool for javascript. It supports many languages (now even Chuvash) for displaying date and time. Another very handy functionality is showing relative time which has a simple interface: fromNow().

Here is a simple example from a web browser console:

moment.lang("cv")
moment().subtract("days", 3).calendar()
//"Иртнĕ вырсарникун 07:30 сехетре"
moment().subtract("days", 3).subtract("hours", 10).calendar()
//"Иртнĕ шăматкун 21:31 сехетре"
moment("2011-10-04", "YYYY-MM-DD").fromNow()
//"10 уйăх каялла"
moment("2012-10-04", "YYYY-MM-DD").fromNow()
//"2 уйăхран"

Previous Issues

UPDATE: It has been released an update of moment.js: 1.7.1 where all of the issues with Chuvash localization are gone.
For Until now there is was one issue with Chuvash localization of moment.js: wrong suffix in future relative time. In most supported languages in moment.js to express something what will happen in future, prepositions (words before, like in, for, by) are used. In the agglunative languages (Basque, Turkish, Korean and Japanese) postpositions (words after) are used. Chuvash is a bit different, the future is expressed by the ablative case.

ikĕ ujăh (2 months) - ikĕ ujăhran (in two months)

Not a big deal, you think? It wouldn’t be if it there wasn’t vowel harmony (front and back vowels):

ikĕ sehet (2 hours) - ikĕ sehetren (in two hours)

Besides vowel harmony the ablative case affix can be ran/ren (after almost all sounds) and tan/ten (after l n r).

ikĕ şul (2 years) - ikĕ şultan (in two years)

For now it is not possible to provide a function for custom logic for future fromNow (like there is such functions for time units: minutes, montsh, years), something like that:

relativeTime : {
	future : function(output) {
		var affix = /сехет$/i.exec(output) 
                     ? "рен" : /çул$/i.exec(output) ? "тан" : "ран";
		return output + affix; 
	}
	//...

And the “humanize” function in moment.js has to be able to handle a function as parameter:

humanize : function (withSuffix) {
	var difference = +this,
		rel = this.lang().relativeTime,
		output = relativeTime(difference, !withSuffix, this.lang());
	if (withSuffix) {
		var rt = difference <= 0 ? rel.past : rel.future;
                //was: output = (difference <= 0 ? rel.past : rel.future).replace(/%s/i, output);
		if (typeof rt === 'function') {
			output = rt(output);
		}
		else {
			output = rt.replace(/%s/i, output);
		}
	}
	return output;
}

Chuvash translation of Wikipedia Mobile

The official Wikipedia mobile app is now translated into Chuvash language and available to use:

What does Chuvash mean?

I am Chuvash. Chuvash is the name of an ethnicity which counts up to 2 milions peoply (mostly in Russia). Chuvashes talk the Chuvash language which is also an official language in Chuvash Republic (besides Russian). Chuvash language is a Turkic language and has a status “Vulnerable” in the UNESCO list of languages in danger. There is a Chuvash Wikipedia cv.wikipedia.org.

What is Wikipedia Mobile?

Wikipedia Mobile is a mobile application which is available on Google Play and App Store. It is written mostly in javascript and uses Cordova (PhoneGap) as a mobile container to interact with a mobile device.

Translation

I translated text strings into Chuvash on translatewiki.net which is used for the translation of wikimedia projects and external projects. Thanks for the tip to @aharoni and Sakha Wikipedia mailing list. If you can write Chuvash, please feel free to correct and add new text strings.

How to use

To be able to see the Chuvash interface we have to have a Chuvash locale. Unfortunately there is no one. If you are using Android then you are a lucky one, you can add any locale with MoreLocale 2 app.

Just install it and add a new locale (cv or cv-RU):

By the way, to write with additional four letters in Chuvash (besides the Russian 33 letters), you can use the Chuvash keyboard layout for Android which I published on Google Play. The most interface on your mobile will use default strings (English), but Wikipedia Mobile’s interface will be completely in Chuvash 🙂

ResxCrunch: Localization tool

If your solution has two or more languages to support, I can recommend an open source tool ResxCrunch.

Btw, you can even use ResxCrunch for localization of Android applications.

ScriptResx.ashx in SharePoint

In my previous post I showed a little proof-of-concept for an httphandler which I want to use to dynamically get the localization resources from SharePoint as javascript object. But wait a moment. How does SharePoint handle localization on client? When you look in Script tab in Chrome dev tools, you’ll find:

ScriptResource.axd

It is added to the server when deployed. See a good introduction to WebResource.axd and ScriptResource.axd by Brian Chavez.

ScriptResx.ashx

That was new. Try to google it. You won’t find much results.

Wait a sec, so there is actually the localization httphandler in SharePoint which I wanted to do?

Can’t be true, can it? Let’s look closer. So the url for this javascript file is:

/_layouts/ScriptResx.ashx?culture=nb-no&name=SP.Res

It is added with RegisterSod:

<script type="text/javascript">
    RegisterSod("sp.res.resx",
        "\u002f_layouts\u002fScriptResx.ashx?culture=nb\u00252Dno\u0026name=SP\u00252ERes\u0026rev=4rLK\u00252F2Oo4ectujVWgrynrA\u00253D\u00253D");
</script>

It begins by:

_EnsureJSNamespace('SP');
SP.Res={lcid:'1044',autocompleteAccessibleMenuName:'Autofullf\u00F8r-meny'....

Very nice. But where resides this SP.Res?… Perhaps, it isn’t a file, rather a name, that the javascript code is encapsulated within. The javascript object is called SP.Res.

By the way, a nice usage of it is to define the current language:

var lang = SP.Res.lcid;

ScriptResx.ashx file is located in Layouts folder and contains only one line:

<%@ WebHandler
   Language="C#" Class="Microsoft.SharePoint.ApplicationPages.ScriptResxHandler,Microsoft.SharePoint.ApplicationPages,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"
     %>

So the class is Microsoft.SharePoint.ApplicationPages.ScriptResxHandler. Google gives no results… The Microsoft.SharePoint.ApplicationPages.dll resides in C:\inetpub\wwwroot\wss\VirtualDirectories\80\_app_bin

This is what .NET Reflector reveals:

The file is loaded is actually 14/Resources/SP.Res.resx:

Usage for other and custom .resx files

Wow, those who read all this, you’ll be awarded: You can actually load any localization files with ScriptResx.ashx (anything which can be found in 14/Resources/-folder, core, spscore and much more, or your own custom resx-files). Just add your script:

<script src="/_layouts/ScriptResx.ashx?culture=nb-no&name=Takana></script>

This will be loaded into “Res”.

One shortcoming is that multiple resx-files would override each other because every localization file loads properties into “Res” object (except SP.Res). Another shortcoming is that we can’t load culture-invariant localization files, because the filePath concatenation is much hard coded: It depends on a dot and culture-name:

Get Culture dynamically

ScriptResx.ashx depends on culture name. Sure we can put this directly in the script tag. But what if you can’t know the current language of the site? It is not so difficult actually, just get the current culture name in the asp.net markup:

<script
    type="text/javascript"
    src="/_layouts/ScriptResx.ashx?culture=<%= System.Globalization.CultureInfo.CurrentCulture.Name %>&name=Takana">
</script>

Update: An even better solution is to use L_Menu_LCID (found on Ruud Heemskerk’s Blog):

<script
    type="text/javascript"
    src="/_layouts/ScriptResx.ashx?culture=" + L_Menu_LCID + "&name=Takana">
</script>
Resolving name conflict

If you load multiple localization files, all will use “Res” name for the localization object and override the latest localizations. To solve it we must catch the Res object and encapsulate it within another object which we have control over. Here we can use many techniques, among them ExecuteOrDelayUntilScriptLoaded (with RegisterSod and LoadSod) from SharePoint, we can use head.js to load and run a callback. But the simplest way is to use jQuery.getScript function:

jQuery.getScript("/_layouts/scriptresx.ashx?culture=nb-no&name=Takana")
	.done(function() { Takana = {}; Takana.Res = Res; })
	.fail(function() {console.log("error");});
Update 2013-02-01

I found a better way to resolve the name conflict for resx-files loaded with scriptresx.ashx. Just update the classFullName resheader in your resx file. Details in my new post:

JavaScript Localization in SharePoint

Push a copy of Resources to client in javascript

In one of my previous posts I told about pushing a copy of an object into client. Now I’ll try to copy my resource values into client. The problem is often that we must create multiple localization resources: first as resx-file. If we use much ajax and client side rendering, we must provide some localization there, too. If they are different subsets of localization resources, it isn’t a problem. But when you get overlapping, it becomes more difficult to manage and sync them.

See how Microsoft Ajax Library provides some strings:

What if we just copy the values from resx file into client? If there are not business constraint it can make the development much easier. Let’s try it. For that we need Reflection. We start with changing the access modifiers on resx file to public:

Then we must get all static properties of the auto-generated class (ResXFileCodeGenerator):

var t = typeof(Takana.Localization);
var props = t.GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
const string f = "\"{0}\":\"{1}\"";
var properties = props.Select(p => string.Format(f, p.Name, p.GetValue(t, null))).ToArray();
var entries = string.Join(",", properties);
var json = string.Format("{{{0}}}", entries);
var script = "var takanaLoc = " + json + ";\n";
Page.ClientScript.RegisterStartupScript(GetType(), "takanaLoc1", script, true);

Hämta lokaliserad sträng från App_GlobalResources

Om man har en sträng i App_GlobalResources som man vill hämta ifrån koden, kör:

string text = HttpContext.GetGlobalResourceObject("MyProject_Global", "submit_label") as string;

Version 0.2.0: Swedish localization

Well, it is time to localize. The first language has been added: Swedish, of course. To localize is pretty simple in Android.

All you have to do is to create a new folder /res/values-xx where xx is the language code. sv is Swedish. In this folder create an xml file called strings.xml and copy all the content from /res/values/strings.xml.

Replace all the strings from your default language into the language you want to localize to. There is a graphical wizzard in Eclipse+Android for creating the right folder: Right click on your project → Android tools → Create a new Resource file → Choose Language → Follow your intution.

Discovering SharePoint

And having fun doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

RealActivity - Real-time and trustworthy

Blog site of founder, RealActivty - Paul J. Swider

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points!!

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis