You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.0 KiB

4 years ago
  1. /**
  2. * Special language-specific overrides.
  3. *
  4. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  5. *
  6. * @type {Object}
  7. */
  8. var LANGUAGES = {
  9. tr: {
  10. regexp: /\u0130|\u0049|\u0049\u0307/g,
  11. map: {
  12. '\u0130': '\u0069',
  13. '\u0049': '\u0131',
  14. '\u0049\u0307': '\u0069'
  15. }
  16. },
  17. az: {
  18. regexp: /[\u0130]/g,
  19. map: {
  20. '\u0130': '\u0069',
  21. '\u0049': '\u0131',
  22. '\u0049\u0307': '\u0069'
  23. }
  24. },
  25. lt: {
  26. regexp: /[\u0049\u004A\u012E\u00CC\u00CD\u0128]/g,
  27. map: {
  28. '\u0049': '\u0069\u0307',
  29. '\u004A': '\u006A\u0307',
  30. '\u012E': '\u012F\u0307',
  31. '\u00CC': '\u0069\u0307\u0300',
  32. '\u00CD': '\u0069\u0307\u0301',
  33. '\u0128': '\u0069\u0307\u0303'
  34. }
  35. }
  36. }
  37. /**
  38. * Lowercase a string.
  39. *
  40. * @param {String} str
  41. * @return {String}
  42. */
  43. module.exports = function (str, locale) {
  44. var lang = LANGUAGES[locale]
  45. str = str == null ? '' : String(str)
  46. if (lang) {
  47. str = str.replace(lang.regexp, function (m) { return lang.map[m] })
  48. }
  49. return str.toLowerCase()
  50. }