I have created a .po file to translate the custom template text. But this isn't what I want to achieve. I only want Wordpress to translate the texts when it's on the matching language code .com/en/... Now it translates everything on the same URL which means I can only see one language and for example not visit the Dutch version by going to .com/nl/..
Is it possible to add language code in the URL which translates to matching language?
Hopefully this makes sense, if not I'll explain better.
To translate a Wordpress Website, you may need a plugin that make this. As much as you add a "/ nl", if you do not have a plugin that translates the whole web and you modify the language of wordpress, the wordpress itself will not know that you have changed the language and will always show the same ".po".
Related
Recently i needed to translate a big website. I translated the Loco PO files with PO Editor.
Then i added it, and now i can have either the original language or the new one at a time.
Loco translate do not provide a solution for makeing a website multilangual.
But, on the Loco Translate official website it tells:
So there is a way to implement it with some coding.
Is there a ready snippet, or a proven working method to make Wordpress Multilangual with Loco Translate and some code snippet?
Thanks for the answers!
If you take a look at the plugin description of you Loco Translate:
Built-in translation editor within WordPress admin
Create and update language files directly in your theme or plugin
Extraction of translatable strings from your source code
https://wordpress.org/plugins/loco-translate/
Loco Translate is a really good plugin if you want to translate strings inside of your theme files or inside of plugins. For this use-case it works perfectly.
If you want to translate the content of your website, so the actual posts and pages with their text and images, you need something different. You do not want to translate strings in the source code, but the content of your pages/posts.
A free solution which I often use is Polylang. It is very easy and also supports custom post types, taxonomies, media, tags and much more, which you can activate or deactivate for translation. You can translate your content to as many languages as you like, a language switcher also is included. Content from one language can be automatically copied over so translating is fast and easy to manage. Really a recommendation from my side.
https://wordpress.org/plugins/polylang/
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'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!
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.