Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support different language on CMS URL Path segment #1557

Closed
apychan opened this issue Oct 18, 2017 · 9 comments
Closed

Support different language on CMS URL Path segment #1557

apychan opened this issue Oct 18, 2017 · 9 comments
Assignees
Milestone

Comments

@apychan
Copy link

apychan commented Oct 18, 2017

For best SEO, I suggest CMS URL Path segment not only accept English alphabets and '-', also accept other language alphabets and maintain accept '-' symbol only.
For example, we have a page call 'new' in English, URL will be http://test.com/en/new
and we also have Japanese version, so the page call '新', URL can be http://test.com/jp/新

But I facing now is if I type non English alphabets and '-', the URL Path segment will auto reject those inputs.
But if I directly change alias field in database, front end still works and can be use other language alphabets

@nadar
Copy link
Contributor

nadar commented Oct 18, 2017

hi @apychan, i just googled very quickly what valid url chars are: https://stackoverflow.com/a/7109208

So i guess this is the reason why this very rare scenario. Am i wrong?

@apychan
Copy link
Author

apychan commented Oct 18, 2017

@nadar
Copy link
Contributor

nadar commented Oct 18, 2017

Okay, i think it does not hurt to allow other chars, its still a user decision what to use. Well then i am going to change the usage of the slug directive a bit.

Thanks for the report anyhow! (Seems like you are speaking Japanese, maybe help translate luya 😄 ?)

@nadar nadar added this to the 1.0.0 milestone Oct 18, 2017
@nadar nadar self-assigned this Oct 18, 2017
@nadar
Copy link
Contributor

nadar commented Oct 18, 2017

Well, i enabled the usage of unicode chars, but now the yii\helpers\Inflector::slug() returns and storesxin-xin-xin-xin instead of 新-新-新-新 in the database.

I assume this is a similar discussion: yiisoft/yii2#10061

@apychan
Copy link
Author

apychan commented Oct 20, 2017

@nadar I can help you to translate, I try to finish before 12/12

and how about this? It is a simple function. How about add a checkbox after aliases field to choose between standard slug function(translated) or SEO slug(only filtered all url and luya not accepted symbol)
https://jsfiddle.net/c0y75h16/1/

@nadar
Copy link
Contributor

nadar commented Oct 20, 2017

@apychan translating would be awesome, i just saw your fork. please make sure to create a clean branch in order to make pull requests and not using the "master" branch.

Well i fixed the problem already on client side (angular) you can try by checking out the dev-master (https://luya.io/guide/install-problems#require-the-dev-master). Its now a problem from http://www.yiiframework.com/doc-2.0/yii-helpers-baseinflector.html#slug()-detail which is validating the slug on server side but converting then the chars due to transliteration method http://www.yiiframework.com/doc-2.0/yii-helpers-baseinflector.html#transliterate()-detail i tryed to changed the transliteration settings of the inflector class but it seems not to work (see related issue from above), but i will find a solution.

@martinpetrasch
Copy link
Contributor

I'll extend the yii helper base inflector as a luya helper and provide a fourth parameter to the original slug function which will give the option to prevent the use of the yii/intl transliterate function. Additionally I'll provide a unit test which will prove the correct transformation (trim, lowercase, etc.) of the original slug function despite the skipped transliteration.

@nadar
Copy link
Contributor

nadar commented Nov 21, 2017

Sounds good to me: luya\helpers\Inflector and then replace the slug() method inside the cms model NavItem.

martinpetrasch added a commit to martinpetrasch/luya that referenced this issue Nov 21, 2017
@nadar nadar closed this as completed in a8cfbfa Nov 21, 2017
@martinpetrasch
Copy link
Contributor

@apychan Thanks again for your input! We've successfully implemented a way to handle non transliterated URL strings and you can now use the feature in the current dev version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants