Support for cyrillic letters in slugs (while in :ru locale) (PR #224)

I’ve fixed an issue occured with empty post slugs (causing routing errors, #217) for posts with titles consisting totally of cyrillic characters.

I’ve added gem russian, which activates correct cyrillic processing when I18n.locale = :ru. Nethertheless, it breaks classical ASCII transliteration, so I’ve messed with I18n.locale variable in slug_spec.rb a little bit.

GitHub

Hmm, I think the better fix is to make sure the empty “topic” string is also honored in the notifications panel for now rather than having a broken URL.

On Thursday, February 21, 2013 at 11:11 AM, Кирилл Пименов wrote:

I’ve fixed an issue occured with empty post slugs (causing routing errors, #217 (https://github.com/discourse/discourse/issues/217)) for posts with titles consisting totally of cyrillic characters. I’ve added gem russian, which activates correct cyrillic processing when I18n.locale = :ru. Nethertheless, it breaks classical ASCII transliteration, so I’ve messed with I18n.locale variable in slug_spec.rb a little bit.
You can merge this Pull Request by running git pull https://github.com/kirushik/discourse slug_russian Or view, comment on, or merge it at: https://github.com/discourse/discourse/pull/224 Commit Summary Support for :ru locale in slugs

File Changes M Gemfile (https://github.com/discourse/discourse/pull/224/files#diff-0) (11)
M Gemfile.lock (https://github.com/discourse/discourse/pull/224/files#diff-1) (3)
M spec/components/slug_spec.rb (https://github.com/discourse/discourse/pull/224/files#diff-2) (9)

Patch Links: https://github.com/discourse/discourse/pull/224.patch https://github.com/discourse/discourse/pull/224.diff

So some URLs are broken, in one locale or other? OK, fair enough. I’ll try to invent some smarter kind on non-character-eating transliteration when my russian l10n will be ready.

Still, the related slug mismatch (empty vs default topic) is difficult for my newbie mind to trace. And I think it won’t be a good idea to short-circuit empty slugs to be treated exactly as default ones…

We definitely need a fix for the broken URL, but I’m not against transliterating foreign locales. We’d looked at ways to do this for many languages, but havent’ yet found a good solution. We found one gem (whose name I forget) which supports many languages including chinese, but it didn’t seem to work with Ruby 1.9.3 :frowning:

If we have to include a russian gem, we should at least conditionally include it if russian is needed somehow. I’m not sure how to do that cleanly though.

Anyway in the meantime thanks for pointing out the notifications error, I’ll look at it soon!

OK. So I’ll prepare and propose pull request with russian i18n, and include the gem there.

Oh, I must mention that russian’s transliteration is active only when I18n.locale == :ru, else it does nothing. There could be some misleading stuff in my initial explanation.

I close this for time, I suppose.