mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
Lib & fichiers de trad
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
(function() {
|
||||
|
||||
var dfs = {"am_pm":["AM","PM"],"day_name":["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],"day_short":["dim.","lun.","mar.","mer.","jeu.","ven.","sam."],"era":["av. J.-C.","ap. J.-C."],"era_name":["avant Jésus-Christ","après Jésus-Christ"],"month_name":["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],"month_short":["janv.","févr.","mars","avr.","mai","juin","juil.","août","sept.","oct.","nov.","déc."],"order_full":"DMY","order_long":"DMY","order_medium":"DMY","order_short":"DMY"};
|
||||
var nfs = {"decimal_separator":",","grouping_separator":" ","minus":"-"};
|
||||
var df = {SHORT_PADDED_CENTURY:function(d){if(d){return(((d.getDate()+101)+'').substring(1)+'/'+((d.getMonth()+101)+'').substring(1)+'/'+d.getFullYear());}},SHORT:function(d){if(d){return(((d.getDate()+101)+'').substring(1)+'/'+((d.getMonth()+101)+'').substring(1)+'/'+(d.getFullYear()+'').substring(2));}},SHORT_NOYEAR:function(d){if(d){return(((d.getDate()+101)+'').substring(1)+'/'+((d.getMonth()+101)+'').substring(1));}},SHORT_NODAY:function(d){if(d){return(((d.getMonth()+101)+'').substring(1)+'/'+(d.getFullYear()+'').substring(2));}},MEDIUM:function(d){if(d){return(d.getDate()+' '+dfs.month_short[d.getMonth()]+' '+d.getFullYear());}},MEDIUM_NOYEAR:function(d){if(d){return(d.getDate()+' '+dfs.month_short[d.getMonth()]);}},MEDIUM_WEEKDAY_NOYEAR:function(d){if(d){return(dfs.day_short[d.getDay()]+' '+d.getDate()+' '+dfs.month_short[d.getMonth()]);}},LONG_NODAY:function(d){if(d){return(dfs.month_name[d.getMonth()]+' '+d.getFullYear());}},LONG:function(d){if(d){return(d.getDate()+' '+dfs.month_name[d.getMonth()]+' '+d.getFullYear());}},FULL:function(d){if(d){return(dfs.day_name[d.getDay()]+' '+d.getDate()+' '+dfs.month_name[d.getMonth()]+' '+d.getFullYear());}}};
|
||||
|
||||
window.icu = window.icu || new Object();
|
||||
var icu = window.icu;
|
||||
|
||||
icu.getCountry = function() { return "" };
|
||||
icu.getCountryName = function() { return "" };
|
||||
icu.getDateFormat = function(formatCode) { var retVal = {}; retVal.format = df[formatCode]; return retVal; };
|
||||
icu.getDateFormats = function() { return df; };
|
||||
icu.getDateFormatSymbols = function() { return dfs; };
|
||||
icu.getDecimalFormat = function(places) { var retVal = {}; retVal.format = function(n) { var ns = n < 0 ? Math.abs(n).toFixed(places) : n.toFixed(places); var ns2 = ns.split('.'); s = ns2[0]; var d = ns2[1]; var rgx = /(\d+)(\d{3})/;while(rgx.test(s)){s = s.replace(rgx, '$1' + nfs["grouping_separator"] + '$2');} return (n < 0 ? nfs["minus"] : "") + s + nfs["decimal_separator"] + d;}; return retVal; };
|
||||
icu.getDecimalFormatSymbols = function() { return nfs; };
|
||||
icu.getIntegerFormat = function() { var retVal = {}; retVal.format = function(i) { var s = i < 0 ? Math.abs(i).toString() : i.toString(); var rgx = /(\d+)(\d{3})/;while(rgx.test(s)){s = s.replace(rgx, '$1' + nfs["grouping_separator"] + '$2');} return i < 0 ? nfs["minus"] + s : s;}; return retVal; };
|
||||
icu.getLanguage = function() { return "fr" };
|
||||
icu.getLanguageName = function() { return "français" };
|
||||
icu.getLocale = function() { return "fr" };
|
||||
icu.getLocaleName = function() { return "français" };
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,86 @@
|
||||
(function() {
|
||||
|
||||
var translate = function(text)
|
||||
{
|
||||
var xlate = translateLookup(text);
|
||||
|
||||
if (typeof xlate == "function")
|
||||
{
|
||||
xlate = xlate.apply(this, arguments);
|
||||
}
|
||||
else if (arguments.length > 1)
|
||||
{
|
||||
var aps = Array.prototype.slice;
|
||||
var args = aps.call( arguments, 1 );
|
||||
|
||||
xlate = formatter(xlate, args);
|
||||
}
|
||||
|
||||
return xlate;
|
||||
};
|
||||
|
||||
// I want it available explicity as well as via the object
|
||||
translate.translate = translate;
|
||||
|
||||
//from https://gist.github.com/776196 via http://davedash.com/2010/11/19/pythonic-string-formatting-in-javascript/
|
||||
var defaultFormatter = (function() {
|
||||
var re = /\{([^}]+)\}/g;
|
||||
return function(s, args) {
|
||||
return s.replace(re, function(_, match){ return args[match]; });
|
||||
}
|
||||
}());
|
||||
var formatter = defaultFormatter;
|
||||
translate.setFormatter = function(newFormatter)
|
||||
{
|
||||
formatter = newFormatter;
|
||||
};
|
||||
|
||||
translate.format = function()
|
||||
{
|
||||
var aps = Array.prototype.slice;
|
||||
var s = arguments[0];
|
||||
var args = aps.call( arguments, 1 );
|
||||
|
||||
return formatter(s, args);
|
||||
};
|
||||
|
||||
var dynoTrans = null;
|
||||
translate.setDynamicTranslator = function(newDynoTrans)
|
||||
{
|
||||
dynoTrans = newDynoTrans;
|
||||
};
|
||||
|
||||
var translation = null;
|
||||
translate.setTranslation = function(newTranslation)
|
||||
{
|
||||
translation = newTranslation;
|
||||
};
|
||||
|
||||
function translateLookup(target)
|
||||
{
|
||||
if (translation == null || target == null)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
if (target in translation == false)
|
||||
{
|
||||
if (dynoTrans != null)
|
||||
{
|
||||
return dynoTrans(target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
var result = translation[target];
|
||||
if (result == null)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
window._ = translate;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user