CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

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;
}
Advertisements

3 responses to “Chuvash localization of moment.js

  1. Tim Wood (@momentjs) 2012-08-14 at 17:26

    Submit a PR with the past/future callback and we’ll definitely pull it in!

  2. Pingback: Chuvash localization - Bool Tech

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy 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

%d bloggers like this: