forked from zhurui/management
55 lines
1.0 KiB
JavaScript
55 lines
1.0 KiB
JavaScript
|
/**
|
||
|
* Special language-specific overrides.
|
||
|
*
|
||
|
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
|
||
|
*
|
||
|
* @type {Object}
|
||
|
*/
|
||
|
var LANGUAGES = {
|
||
|
tr: {
|
||
|
regexp: /\u0130|\u0049|\u0049\u0307/g,
|
||
|
map: {
|
||
|
'\u0130': '\u0069',
|
||
|
'\u0049': '\u0131',
|
||
|
'\u0049\u0307': '\u0069'
|
||
|
}
|
||
|
},
|
||
|
az: {
|
||
|
regexp: /[\u0130]/g,
|
||
|
map: {
|
||
|
'\u0130': '\u0069',
|
||
|
'\u0049': '\u0131',
|
||
|
'\u0049\u0307': '\u0069'
|
||
|
}
|
||
|
},
|
||
|
lt: {
|
||
|
regexp: /[\u0049\u004A\u012E\u00CC\u00CD\u0128]/g,
|
||
|
map: {
|
||
|
'\u0049': '\u0069\u0307',
|
||
|
'\u004A': '\u006A\u0307',
|
||
|
'\u012E': '\u012F\u0307',
|
||
|
'\u00CC': '\u0069\u0307\u0300',
|
||
|
'\u00CD': '\u0069\u0307\u0301',
|
||
|
'\u0128': '\u0069\u0307\u0303'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Lowercase a string.
|
||
|
*
|
||
|
* @param {String} str
|
||
|
* @return {String}
|
||
|
*/
|
||
|
module.exports = function (str, locale) {
|
||
|
var lang = LANGUAGES[locale]
|
||
|
|
||
|
str = str == null ? '' : String(str)
|
||
|
|
||
|
if (lang) {
|
||
|
str = str.replace(lang.regexp, function (m) { return lang.map[m] })
|
||
|
}
|
||
|
|
||
|
return str.toLowerCase()
|
||
|
}
|