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

Default language hidden from url #12

Open
rafatrace opened this issue Nov 3, 2015 · 7 comments
Open

Default language hidden from url #12

rafatrace opened this issue Nov 3, 2015 · 7 comments

Comments

@rafatrace
Copy link

Hi, how are you?

Is there an option to hide the default language from the url?

Imagine a portuguese app, but also has english translation. 85% of the users are portuguese and 15% aren't. Would make sense to hide /pt since 85% users are portuguese and seeing that in the URL will not matter. Or in the case that I'm building an app that currently supports one language only (but in a near future could turn multilang), so I use Multilang Class thinking about the possibility of having a new language added in the future. If this is the case, all my urls will show /pt although my website only has Portuguese at the moment.

Example urls:

https://my-app.com/ (Portuguese)
https://my-app.com/users (Portuguese)
https://my-app.com/books (Portuguese)
https://my-app.com/books/1 (Portuguese)

https://my-app.com/en (English)
https://my-app.com/en/users (English)
https://my-app.com/en/books (English)
https://my-app.com/en/books/1 (English)

Its probably an aesthetic question, but would be nice to see this implemented. (Since I've faced this problem already).

Cheers.

@xfra35
Copy link
Owner

xfra35 commented Nov 3, 2015

Hey Rafael, I'm fine thanks!

Have you considered setting the migrate flag on? It would automatically permanently redirect /users to /pt/users.

From my experience, leaving primary language URIs untouched can be attractive at the beginning of the localization but makes routing messy on the long term. Also clear language separation at the URI level is said to improve SEO.

Anyway, since this feature has been requested a few times already (cf. issue #5 for example), I'll probably add it some day :P

@rafatrace
Copy link
Author

Glad to hear that, I'll reconsider your suggestion. 👍
Thanks ;)

@eazuka
Copy link

eazuka commented Mar 14, 2019

Hello @xfra35, thanks for the nice job you've done with this f3 multilang plugin.

I also want to use this plugin for a multi-language project and just like others, i also desire that the default language not show in url, so an option to hide the default language from the url would be awesome.

Its going 4yrs since @rafaelsnts opened this issue, I will just like to know if you later added this feature request to hide default/primary/fallback language from the url? if yes, how can it be activated?

@SuN-80
Copy link

SuN-80 commented May 11, 2020

I'm not sure why @xfra35 didn't add this option yet, so here is my fork (#24) for those who want to hide subfolder for main language : https://github.com/SuN-80/f3-multilang/blob/master/lib/multilang.php

You can disable the subfolder for main language by setting MULTILANG.hide to TRUE, like this: $f3->set('MULTILANG.hide', TRUE);

@sbraaa
Copy link

sbraaa commented May 21, 2021

Hi @xfra35 I'm also interested in the requested feature, any plan to implement it in the near future?
By the way, thank you for this usefull plugin!

@sbraaa
Copy link

sbraaa commented May 21, 2021

I'm not sure why @xfra35 didn't add this option yet, so here is my fork (#24) for those who want to hide subfolder for main language : https://github.com/SuN-80/f3-multilang/blob/master/lib/multilang.php

You can disable the subfolder for main language by setting MULTILANG.hide to TRUE, like this: $f3->set('MULTILANG.hide', TRUE);

Hi @SuN-80 , I've tried your patch but it doesn't run as expected and I cannot understand what's wrong.
in my config.ini I put:

[MULTILANG]
hide=TRUE
;root = /it

[MULTILANG.languages]
it = it-IT, it
en = en-GB, en-US, en
de = de-DE, de

Italian would be main language but when I try to access it redirects to mydomain/it instead of mydomain/ so I see 404 error (note that MULTILANG.root is commented!).

CACHE is set to FALSE and I deleted all the files in tmp, any advice?

@am3000
Copy link

am3000 commented Nov 6, 2023

I'm not sure why @xfra35 didn't add this option yet, so here is my fork (#24) for those who want to hide subfolder for main language : https://github.com/SuN-80/f3-multilang/blob/master/lib/multilang.php
You can disable the subfolder for main language by setting MULTILANG.hide to TRUE, like this: $f3->set('MULTILANG.hide', TRUE);

Hi @SuN-80 , I've tried your patch but it doesn't run as expected and I cannot understand what's wrong. in my config.ini I put:

[MULTILANG]
hide=TRUE
;root = /it

[MULTILANG.languages]
it = it-IT, it
en = en-GB, en-US, en
de = de-DE, de

Italian would be main language but when I try to access it redirects to mydomain/it instead of mydomain/ so I see 404 error (note that MULTILANG.root is commented!).

CACHE is set to FALSE and I deleted all the files in tmp, any advice?

I also had the issue that the home page did not work.
I think you can fix it with MULTILANG.root, but I simply changed the last line of the multilang.php from

$this->f3->route('GET /', @$config['root'] ?: function( $f3 ) use ( $self ) {$f3->reroute('/' . $self->current);});

to

if($this->hide!=TRUE || $this->current != $this->primary ) {
     $this->f3->route('GET /', @$config['root'] ?: function( $f3 ) use ( $self ) {$f3->reroute('/' . $self->current);});
}

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

No branches or pull requests

6 participants