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

language code bug when save as ca-valencia or any code with more than 5 characters #1667

Closed
robthepaper opened this issue Apr 29, 2019 · 15 comments

Comments

@robthepaper
Copy link

Hi,
I would like tom ake a special use of the language. Instead of language I would use a city name of the same language.
I noticed if the language code you add in system.yaml is more than 5 character,
the file that is writen does'nt work correctly.

For instance if I add language fr-paris and in my page I save as frparis,
grav redirects me to login and the file written looks like this default.frparis.frparis.md
whereas if the language code is no morethan 5 character like paris, it's working and the file is written properly : default.paris.md

If I try with ca-valencia which is in the laguage code array (LanguageCodes.php), it's the same.

Does anyone know a way I can use language code that is more than 5 characters?

Thanks

@rhukster
Copy link
Member

this could well be an admin plugin specific issue. Are there any issues if you manually create the default.frparis.md file?

@robthepaper
Copy link
Author

if I do that I do have frparis in the language dropdown list for my page but when I save it redirects me to the login page.

@robthepaper
Copy link
Author

My current grav version is 1.5.6 was thinking maybe upgrade to see if the issue still occurs

@rhukster
Copy link
Member

Don't think it will make a difference. Nothing changed regarding languages between 1.5 and 1.6. I'm looking into it

@rhukster
Copy link
Member

Ok, testing so far. Without admin, just creating a default.ca-valencia.md file seems to work fine. I Don't think it's a Grav core issue, must be something specific to admin.

@rhukster
Copy link
Member

What you described with redirecting you to login, is related to admin right? I see that also. Moving this to admin repo.

@rhukster rhukster transferred this issue from getgrav/grav Apr 29, 2019
@robthepaper
Copy link
Author

I think so, I must login again to re-access admin

@robthepaper
Copy link
Author

Oh, no, it's just that it redirects to http://localhost/frparis/admin/pages/home instead of http://localhost/admin/pages/home

@rhukster
Copy link
Member

ok, this is a multi-part issue.. there actually are some legit Grav side issues.. I think I have addressed these here: getgrav/grav@4f83b5d

Now I need to tackle the admin issues that are related to the saving of the filenames.

@robthepaper
Copy link
Author

robthepaper commented Apr 29, 2019

I kept on searching to find a temporary fix.
I found at line 2376 of plugins/admin/classes/admincontroller.php,
the function determineFilenameIncludingLanguage is responsible for the filename.
I commented the following at line 2385 :
//$filename .= '.' . $language;

now the filename is correct but it still redirect to
http://localhost/frparis/admin/fr/admin/pages/home

Maybe redirection path is somewhere in the taskSaveas at line 2324 function...

@rhukster
Copy link
Member

Please try with the Fix above, this should handle the different scenarios safely.

@rhukster
Copy link
Member

The redirection to login issue is sorted by the commit in grav i referenced a little further above.

@robthepaper
Copy link
Author

works perfect! thanks!
are the commits going to be included in next version of grav or should I fix the codes after each update?

@rhukster
Copy link
Member

They will be in next set of releases

@robthepaper
Copy link
Author

robthepaper commented Apr 30, 2019

As I will have more than 170 cities,
I just adding a css modification of the file user/plugins/admin/theme/grav/css-compiled/template/_buttons.scss at line 72 to get a scrollingbar in the dropdown menu.
I put it here for reference :

.button-group .dropdown-menu.language-switcher { min-width: 50px; max-height: 300px; overflow: scroll; }

.button-group .dropdown-menu.lang-switcher { min-width: 150px; left: inherit; right: 0; max-height: 200px; overflow: scroll; }

@mahagr mahagr closed this as completed Jan 29, 2020
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