mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Add stringex for Chinese slug generation
This commit is contained in:
parent
968bcd5acb
commit
667758ff40
8 changed files with 39 additions and 5 deletions
|
@ -1,10 +1,17 @@
|
|||
# encoding: utf-8
|
||||
|
||||
|
||||
module Slug
|
||||
|
||||
def self.for(string)
|
||||
slug = string.gsub("'", "").parameterize
|
||||
slug.gsub!("_", "-")
|
||||
if ['zh_CN', 'ja', 'ko'].include?(SiteSetting.default_locale)
|
||||
unless defined? Stringex
|
||||
require 'stringex_lite'
|
||||
end
|
||||
slug = string.to_url
|
||||
end
|
||||
slug =~ /[^\d]/ ? slug : '' # Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue