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";
Related
we are using realurl 1.13.6 and looking forward to enable a third language. The pages have translated content and the switch works well. Since we also added translated page paths we encounter the possible duplicate content issue by google, since the same page / language is available via /nl/dutch-title/ and /nl/german-title/
The "nl" is used to set the language to dutch and the left over to determine the page. Since both paths are leading to the same page_id and the language ist set to "nl_NL" both could trigger the duplicate issue...
Is there a way to restrict realurl to only allow translated page paths matching the active language? Or redirect to the correct translation of the path?
"A": /de/german-path/ -> page id 10 de_DE content
"B": /nl/dutch-path/ -> page id 10 nl_NL content
"C": /nl/german-path/ -> redirect to "B"
In case "C" we want the path to be corrected if the path does not match the nl_NL path translation. If that is not possible a strict mode only allowing translated paths matching the active language in some way would be nice - redirecting to 404 with wrong path.
Is this handled in newer versions of realurl, maybe upgrading is all we need?
Someone already solved a similar issue?
Any help is highly appreciated.
Thank you for reading!
I would solve this by adding a canonical URL. That makes sure the search engines know what URLs to index and the user doesn't get a 404.
Btw search engines don't invent the URLs themselves so don't think there is a great risk that the wrong URLs are indexed.
Unfortunately, the page patch "cache" of RealURL 1.x is not aware of the language of the entry. Therefore, you can observe exactly the behaviour you encountered: all pages are reachable from all paths, regardless of the path’s language. The language of the actual content is only determined by the value of L, which, in your case, is translated to the language prefix.
There is no way to check the language of a path entry, unfortunately, and implement the redirect you desire, unless you patch RealURL yourself.
I would thus also recommend using Frans’ approach of defining a canonical URL (which is good anyways).
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'
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
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.
Hello all and thanks in advance for taking a look and I appreciate any help possible. I'm an SEO guy and have inherited a CakePHP site that will serve content in three languages. I'd like to get a canonical (seo friendly) way to get a good multilingual URL architecture without making my developer too upset.
The end solution of what we want:
Nice URLs with three distinct URLs (translated) for each language. For example:
www.domain.com/L1/language-1-parent/language-1-child/
www.domain.com/L2/language-2-parent/language-2-child/
www.domain.com/L3/language-3-parent/language-3-child/
Here, we have one content piece. This content will be the same in all three languages, but it will be translated. Accordingly, we want the corresponding subdirectories and URIs to be translated as well, where:
L{1-3} are subdirectories indicating the language
language-{1-3} are 'controllers' for the content. Currently we only have one controller, regardless whether the language subdirectories are in a different language).
langauge-{1-3}-child are dependent content items or subdirectries that must also be translated based upon the language subdirectories
The Assumed Problem:
My developer is telling me that because Cake has controllers that serve the content up and as such having translations is a bit messy.
In the example above: I assume that 'language-1,' language-2,' and 'language-3' are the controllers.
Also, I'm assuming that because we're trying to serve up three content versions from one controller (with different URLs), we're running into a problem.
Currently we have URLs as such:
www.domain.com/L1/language-1-parent/language-1-child/
www.domain.com/L2/language-1-parent/language-1-child/
www.domain.com/L3/language-1-parent/language-1-child/
The problem here is that regardless whether a user selects a different language, we have the URLs that do not correspond and are not translated.
Also, we do have some content items that do not have other language translations. As such, I want to put in a rel=canonical meta tag on the pages without translations and/or noindex these pages whilst we{re working on translations.
Again, your help is MASSIVELY appreciated and I look forward to your responses. I'm happy to clarify anything.
With standard cakephp configuration you can easily achieve these kind of URLs using cakephp internationlization
/eng/users/account
/fre/users/account
If you need these king of URLs
/eng/users/account
/fre/utilisateurs/compte
Then you should play with your AppController.php
// pseudo code, you need to rewrite this section as you need.
var lang getUrlParams['language'];
var controller getUrlParams['controller'];
var action getUrlParams['action'];
if (controller[lang] != controller || action[lang] != action) :
redirect to `/lang/controller[lang]/action[lang]`;
endif;
In view's all links should be called like
$this->Html->link(__('My Link'), array('controller' => __('users'), 'controller' => __('account')))