From 8a236c06e282e7bc64e2bf963d52ade261755255 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Thu, 26 Feb 2015 21:49:24 +0100 Subject: [PATCH] FEATURE: Adds transliteration of German umlauts in slugs - Moves the already existing transliteration rules into `transliterations.en.yml` (there's no need to translate this for every language). The same goes for the stringex configuration. - Doesn't calculate the default slug for *zh_CN* and *ja* anymore. It hasn't been used anyway since stringex is used instead. - Removes a wrong comment from the Russion transliteration file (I hate wrong comments) --- config/locales/server.en.yml | 12 ------------ config/locales/transliterate.de.yml | 18 ++++++++++++++++++ config/locales/transliterate.en.yml | 20 ++++++++++++++++++++ config/locales/transliterate.ru.yml | 3 --- lib/slug.rb | 5 +++-- 5 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 config/locales/transliterate.de.yml create mode 100644 config/locales/transliterate.en.yml diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 3431c329da..e5c1b30b90 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -15,18 +15,6 @@ # http://yamllint.com/ en: - stringex: - characters: - ellipsis: "" - number: "-" - # some default transliteration rules may be missing, add them to your locale - i18n: - transliterate: - rule: - ț: "t" - Ț: "t" - ș: "s" - Ș: "s" dates: short_date_no_year: "D MMM" short_date: "D MMM, YYYY" diff --git a/config/locales/transliterate.de.yml b/config/locales/transliterate.de.yml new file mode 100644 index 0000000000..842ff6111d --- /dev/null +++ b/config/locales/transliterate.de.yml @@ -0,0 +1,18 @@ +# encoding: utf-8 +# +# This file contains transliteration rules for German +# +# To validate this YAML file after you change it, please paste it into +# http://yamllint.com/ + +de: + i18n: + transliterate: + rule: + Ä: "Ae" + Ö: "Oe" + Ü: "Ue" + ß: "ss" + ä: "ae" + ö: "oe" + ü: "ue" diff --git a/config/locales/transliterate.en.yml b/config/locales/transliterate.en.yml new file mode 100644 index 0000000000..28dd2e2e7c --- /dev/null +++ b/config/locales/transliterate.en.yml @@ -0,0 +1,20 @@ +# encoding: utf-8 +# +# This file contains default transliteration rules and configures stringex +# +# To validate this YAML file after you change it, please paste it into +# http://yamllint.com/ + +en: + stringex: + characters: + ellipsis: "" + number: "-" + # some default transliteration rules may be missing, add them to your locale + i18n: + transliterate: + rule: + ț: "t" + Ț: "t" + ș: "s" + Ș: "s" diff --git a/config/locales/transliterate.ru.yml b/config/locales/transliterate.ru.yml index 25c4715b48..17a88b47fd 100644 --- a/config/locales/transliterate.ru.yml +++ b/config/locales/transliterate.ru.yml @@ -2,9 +2,6 @@ # This file contains content for the i18n transliteration map from # Russian Cyrillic to ASCII (ISO-9:1995 / GOST 7.79-2000, table B) # -# To work with us on translations, see: -# https://www.transifex.com/projects/p/discourse-pt-br/ -# # To validate this YAML file after you change it, please paste it into # http://yamllint.com/ diff --git a/lib/slug.rb b/lib/slug.rb index 8d6ab1fa6f..6152077235 100644 --- a/lib/slug.rb +++ b/lib/slug.rb @@ -4,8 +4,6 @@ module Slug def self.for(string) - slug = string.gsub("'", "").parameterize - slug.gsub!("_", "-") # TODO review if ja should use this # ko asked for it to be removed if ['zh_CN', 'ja'].include?(SiteSetting.default_locale) @@ -13,6 +11,9 @@ module Slug require 'stringex_lite' end slug = string.to_url + else + slug = string.gsub("'", "").parameterize + slug.gsub!("_", "-") end slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's. end