pid / speakingurl

Generate a slug – transliteration with a lot of options
http://pid.github.io/speakingurl/
BSD 3-Clause "New" or "Revised" License
1.12k stars 84 forks source link

russian example - speaking url is translating to english... #11

Closed kimptoc closed 11 years ago

kimptoc commented 11 years ago

Hi,

I am looking to "slugify" the following: ревущий фьорд

I am hoping to get: ревущии-фьорд

This is what speakingurl currently does:

slug=require("speakingurl")
[Function: getSlug]
> slug("ревущий фьорд")
'revushij-ford'
> slug("ревущий фьорд",{lang:'ru'})
'revushij-ford'

Is there an option keep the original characters, but simplified (as I am hoping)?

For background, these are slugs that the World of Warcraft api uses - so I am trying to mimic what it does.. so, perhaps not the best way round of doing this...

Thanks, Chris

pid commented 11 years ago

hi,

1) I have to clarification something (will add this to the documentation),... the lang-config option select to target language for the symbol translations 'ru': { '∆': 'delta', '∞': 'beskonechno', '♥': 'lubov', '&': 'i', '|': 'ili', '<': 'menshe', '>': 'bolshe', '∑': 'summa', '¤': 'valjuta' }

2) your example:

slug("ревущий фьорд") 'revushij-ford'

you pointed it, that it should "ревущии-фьорд", that wasn't the aim what the module should do... I have to think about it, want to avoid quick shots... what you can do at the moment, a) fork it and adjust it for your needs, maybe we can merge it (don't know at the moment if I should, see above) or b) you use the custom config

var customRU = { "в": "в", "и":"и", "й":"и", ... };

slug = getSlug("ревущий фьорд", {lang: "ru", custom: customRU};

we could add your customRU map to a new lang-directory, so other users can benefit from your work

what do you think?

thanks, Sascha

pid commented 11 years ago

I'm not familiar with the russian language, nor with the speakingurl/slug in "russian-URLs", after I pondered a bit about the issue, it could be useful that we add the charmap you prefer to the translation-map if the module user set lang to "ru" . If the user set lang != "ru" the preferred result of the input string "ревущий фьорд" should be 'revushij-ford' but with lang == "ru" it should be "ревущии-фьорд"

Can you provide the char-map?

{ "в": "в", "и":"и", "й":"и", ... }

it have to contain all russian letters

kimptoc commented 11 years ago

Hi,

More of a ramble than a full response so far...

Thanks for the detailed responses - unfortunately, I dont know Russian either :( - just working with the WoW API that supports Russian and just trying to help my Russian users :)

An example API url is this:

http://eu.battle.net/api/wow/character/%D1%81%D0%B2%D0%B5%D0%B6%D0%B5%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%20%D0%B4%D1%83%D1%88/%D0%B8%D0%B7%D0%B8%D0%B5%D0%BD%D0%B4%D0%B6%D0%B0%D1%81%D1%82?fields=achievements,guild,feed,hunterPets,professions,progression,pvp,quests,reputation,stats,talents,titles,items,pets,petSlots,mounts&locale=ru_RU (looks better in the browser url line...)

One of your examples was this:

"Schöner Titel läßt grüßen!? Bel été !" // Output: schoener-titel-laesst-gruessen-bel-ete

From your comments above, I presume there is a (built-in?) map, for things like 'ö' -> 'oe'

I was hoping there was some magic, that was doing it 'automagically' ... but I guess I need to look at this page: http://en.wikipedia.org/wiki/Russian_alphabet and map it manually.

Tried asking Blizzard, but no response yet: http://us.battle.net/wow/en/forum/topic/8891779533

Also been looking at other/similar libraries, such as - https://github.com/jprichardson/string.js/issues/43 - where they are also not sure how to handle this kind of thing.

PS would be good to handle Chinese, Mexican, .... too. :)

pid commented 11 years ago

only for completeness, this is the aim, what this module pursued -> http://en.wikipedia.org/wiki/Transliteration

back to your example:

I am looking to "slugify" the following: ревущий фьорд I am hoping to get: ревущии-фьорд

what systematic is there? Should only diacritics (diacritical mark, diacritical point, diacritical sign) be deleted/removed?

kimptoc commented 11 years ago

Hi,

Oh - well, I think the transliteration goal looks quite different to what I am after.

The problem I have is that I dont know the systematic :(

I think its just removing diacritics - but far from sure. I think I should get a definitive answer from the source and then look into how best to handle.

Many thanks for the discussion, Chris

pid commented 11 years ago

ok, good luck ;-)

kimptoc commented 11 years ago

Thanks.