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

Slight annoyance with the languages #110

Open
angelxaces opened this issue May 2, 2017 · 2 comments
Open

Slight annoyance with the languages #110

angelxaces opened this issue May 2, 2017 · 2 comments

Comments

@angelxaces
Copy link

First off I totally support the incorporation of languages on this as it's probably allowed more people to contribute. So I don't think it should be taken out. I needed it to toggle off and on though and the problem lies in passing the variable through the uri. The /en/ wasn't something I was fond of having all the time but depending on how you disable it you'll end up with the correct url but the /en will still get appended to file downloads.

My fix was to pass it with sessions or cookies but another way that is similar to the current method would be to pass it using the CodeIgniter's GET array. It's practically the same thing but it doesn't manipulate the URL.

@Nouman24
Copy link

@waifung0207 @angelxaces I am unable to switch among two languages and translate default menu.

This is default url: http://localhost/study/en/

when I switch language by staying on another page like url: http://localhost/study/zh/about-us

and I get page not found error, plus it does not translate the menu:

$lang['about_us'] = "关于我们";

or

$lang['home'] = "主页";

Can you please help me in this?

@angelxaces
Copy link
Author

angelxaces commented Jun 14, 2018

@Nouman24
If you've cloned from my version I strongly recommend that you rebase from the orig/Master but from the URL you've provided that doesn't seem to be the case.

In the original Master branch the URL always has the language appended to the end of the URL string. This means that:
http://localhost/study/zh/about-us
would produce a 404 while:
http://localhost/study/about-us/zh
I believe will work just fine (language is set to be attached at the end).

If you're interested:
In my version I've bypassed the languages for the time being and kept the default at English*, and I removed it from the url string as it interfered with lining and self-referencing urls. I don't remember if I got this far but I know I'm at least close to Passing the language in a cookie (if I recall correctly, perhaps it was a session). In any case, you could do the same for any other language:

if (isset($_SESSION['lang']) && $_SESSION['lang'] != NULL){
return true;
}else{
$SESSION['lang'] = 'zh';
}

and then have /application/core/MY_Controller.php collect the language from session instead of the URL. But then, in the same file, you have to recode the part that self-references the URL as well as the RegEx expression(s) in /application/config/routes.php but the result is that you no longer have the language url-segment interfering with linkage

You know what they say,
What do you call a person who speaks 2 languages? Bilingual.
What do you call a person who speaks one language? American!

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

2 participants