ci_bootstrap_3 icon indicating copy to clipboard operation
ci_bootstrap_3 copied to clipboard

Slight annoyance with the languages

Open angelxaces opened this issue 7 years ago • 2 comments

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.

angelxaces avatar May 02 '17 15:05 angelxaces

@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?

Nouman24 avatar Jun 13 '18 09:06 Nouman24

@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!

angelxaces avatar Jun 14 '18 14:06 angelxaces