Codeigniter Multi-lingual language identifier - php

I am trying to implement CI uri identifier plugin - http://codeigniter.com/wiki/URI_Language_Identifier/
I set the code on a base codeignitor setup. The “ingore_lang” is set to “en”. I am using “alt_site_url” to generate alternative language links.
Now with english it is working all good, links are fine.
But when I click on any other language, the next set of alternate language urls is not replacing the abbr to the present link. For eg. if Spanish is selected, on the new page the link to italian language becomes:
mysite/es/it
I have also observed that the alternate language links never show “english” in the list. I assume they are still taking english as current language.
Please help, am I missing something? I applied the code to all specified files as guided.
Thanks

You should remove 'en' from the lang_ignore var, that should add english to alt languages list. Not sure about the es/it part...

Could you post the code of the implementation you used? I'm also using this in my application and it works fine for me.

Related

Set Language for JText::_()

Setting:
7 System Lanaguages
An editor page which is entirely German (no language switcher).
However part of the page is a preview screen where the editor ought to see the edited content already translated into the respective System Language.
Is there a way I can give JText::_('TRANSLATE_STRING') a parameter which determines the target language of the translation?
Is there another function which gives easy access to the translation?
Or can I change the current language of the Session programatically?
I am a little lost on the documentations I find online and stuck without the right ideas or terms to research.
JFactory::getLanguage() will get you the current language object (JLanguage instance).
JLanguage::getInstance($lang) can get you the language instance you want. You'll need to specify the language code as parameter. You can then use the instance to translate language resources.
For example:
$lang = JLanguage::getInstance('de-DE');
echo $lang->_('TRANSLATE_STRING');
Would output the german version of 'TRANSLATE_STRING'

How to change the language of a website in php

I've been searching over the internet about this problem a week ago but I could not get the exact answer. I went to my friends who are also web developers but they could not give me the right answer.
I just want to know how to change the language of my website to the desired language by the user. In my case, I used drop down button and if the user change the language, let's say for example, from English to Chinese vv, the website's text will change to automatically chinese. These, texts came from the database.
Does anybody know about this? Need much help. thanks
You need load different text from a database according to users selection (usually stored as session data). For very small list such as menu text, you can store them in your script.
If you just want to change front end text and has no functionality of storing that in database, then i will recommend you to use google translate tool for the websites.
Refer this link for the plugin: https://translate.google.com/manager/website/
I hope this helps you.
You can use i18n to create a multilingual website. To do this follow the link
http://www.onlinetutz.com/create-a-multilingual-website-using-php-with-i18n/
it helps you!!

Codeigniter multilanguage uri without language part

I've searched a lot and found even more topics on CI's multilanguage URLs. But most of the answers have no longer working links to CI wiki or doesn't explain a bit of what I want.
My default is a non English language, but I want controllers and methods named in English. I also don't want language segment appear in my URL (at least not for default language).
Eg.:
Default uri - example.com/blogas/irasas/123
English uri - example.com/blog/item/123 or example.com/en/blog/item/123
Links in both languages should call Blog::item()
Generating uris should be similar - site_url('blog/item/123'); should result a link in user language:
Default - example.com/blogas/irasas/123
English - example.com/blog/item/123 or example.com/en/blog/item/123
User language should be set in a cookie or session preferably.
Is there any way to achieve this?
Using latest CI 2.2.0
I believe this solution for 2.1 should work, but I can't figure out how URI's should be translated (where to put translations) and how to remove language part from URI.
May be I am wrong but what I understood is that you are trying to generate different urls based on active language using same words in site_url. If this is correct you can simply translate your words using language helper.
site_url(lang('blog_item_url') . '123);
And in your english langugae file.
$lang['blog_item_url'] = "blog/item/";
And in your other langugae
$lang['blog_item_url'] = "blogas/irasas/";
And define routes in route.php in configurations.
$route['blog/item/(:num)'] = "blog/item/$1";
$route['blogas/irasas/(:num)'] = "blog/item/$1";

Joomla language switcher override

I'm trying to force the language swither module not to redirect to the home page if there is no menu item associations in Joomla 2.5.
I would just like to change country code in the current URL.
So that 'my-domain.com/en/menu?view=cat&id=1' translate to: 'my-domain.com/de/menu?view=cat&id=1' and so on ...
I guess I should modify modLanguagesHelper class but do not know how to create a required $language->link to work properly through JRoute.
Any help is appreciated!
Joomla usually does that by default. It seems strange that it doesn't with the approach you have followed.
Although, reading the comments you left, I understand it's not an easy task and you have already built quite a big part of the website, to go back to structure.
If I were you, I would write a small custom module to change the lang=xx or /xx/ in the URL, and redirect the user to the language they want. If you need help on that, feel free to comment below.
As per your question, I would personally go with simple string manipulation. Since you are really familiar with PHP (taking into consideration that you have written your own custom component), it should be a piece of cake for you, to:
Get the current URL
Get the current language tag
Replace the instances of lang=en with lang=de (example languages, you get the point)
Replace the instances of yoursite.com/en/ with yoursite.com/de/
Print the custom links, flags or whatever you are going to use.
It's not the suggested scenario, but you can really make a usable module if you also add:
An option for the administrator to write the language codes to use (to allow for later additions)
And make sure that you get the site name dynamically, and then you may also have a module that could be published in the JED to help others in the same situation like you!

Joomla Multiple language

I installed joomla language extension and it works fine with the Joomla Administration panel. Now my requirement is to provide language changing option on my front end. Let's say once someone select French he should get existing French articles. And if he change the language to English he should get English articles.
I searched google, but I couldn't get any clue how to get done this. Any help or article highly appreciated.
Thanks.
Simple answer, when you submit an article / add them / whatever you can tag them with the language and then load it from there.
And of course if you are taking articles from a whole bunch of other sites, what you can do to automate this process is to take 300-500 of the most used words / characters that are specific to that particular language and then determine it from there. If you get other articles that you cannot determine, add more words or do it manually
protip: words like "or" and "and" are quite often used consider using them
If you are using Joomla 1.5, you may be interested in this component:
Joomfish
It doesn't work exactly as you said. For example, if you create your articles in English, you can translate them, so when a user views your site in French, he will get the French translation of that article, or the English version of the article if you haven't translated it.
This component also bundles a language switcher module.
If you're using Joomla 1.7, you already have a language switcher module and a language manager, but I think it won't fit to your needs if you need to have completely different articles for different languages, it's intended to have the same articles in different languages.
I hope it helped!
Finally I found relevant language extensions from following link.
http://joomlacode.org/gf/project/jtranslation1_6/frs/?action=index

Categories