mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
8a236c06e2
- 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)
21 lines
519 B
Ruby
21 lines
519 B
Ruby
# encoding: utf-8
|
|
|
|
|
|
module Slug
|
|
|
|
def self.for(string)
|
|
# TODO review if ja should use this
|
|
# ko asked for it to be removed
|
|
if ['zh_CN', 'ja'].include?(SiteSetting.default_locale)
|
|
unless defined? Stringex
|
|
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
|
|
|
|
end
|