Show posts for default language if switched to language that has no posts added yet - multilingual

I have a site that uses Polylang plugin for languages. I have two languages, one default and another. All posts currently are added using default language, but when I switch to another language, nothing has been showing up. I would like in this case show content from default language instead and use another language when it will be added. Is it possible to make this happen?

No, it is not possible to fallback to the default language using the Wordpress Polylang plugin. From https://wordpress.org/support/topic/fallback-to-default-language/ :
This is not possible. There is no feature like this.
The only way to do this is to “translate” the post and page but to add the default language content instead of the translated content. So technically the post and page is “translated” but the content is still the same.
However, there seems to be a Wordpress plugin that does offer this functionality. The project is not very active, however. Perhaps you could pick up a clue on how to approach this problem from its source code.

Related

How to make React app that support multilanguage?

I have reacted app and there are many components, and I want that the text will support multiple languages,
I mean if the user wants English then all content of the component translates into English.
I try to add multilanguage in my react app using the i18next library but I found that I need to write all text in every language and store somewhere then use that.
But I want it when the user selects language and then it translates into the desired language without hard code.
like when we write anything in google translator then it translates all the page with the desired language.
If you want the content of your site to be machine translated on the go, then some browsers (if not all of them) have this built-in functions. Just right click and "translate" the page. So maybe you should just mention about this function somewhere on the page?)
But if you want the content of your site to be professionally translated, then you've got to store it in the db. And depending on the global language state (which could be managed with redux), the content in selected language will be rendered.
Live translation on your website is not a good idea.
Alternatively, checkout translate.i18next.com
like google translate but for i18next.

How should I approach combining react-i18next with content which is fetched from database?

I have a React application and I want to make it a multi-language webpage (English and Bulgarian). So far I've got the hang of translating the static content, such as header, footer, navigation buttons, homepage components, etc. But let's say that I have a list of posts in both languages that gets fetched from my database and I would like to display them according to the language that the user has selected. What would be the most reasonable approach in this situation? My initial guess was to check for the currently selected language and fetch the posts that correspond to that language. Is there a better way to do achieve this?
With your use case, having a bigger amount of text, I think it is the best if you use the currently used language, i.e. i18next.resolvedLanguage and fetches the appropriate blog post.

Locale and dynamic multi language support in EXJS 6

According to docs, the app.json only allows to define one locale.
locale: "fr"
What happens if I have a multiple language application and I want users to select dynamically their language?
How can I include more than one locale ?
And then, how can I dynamically load the locale with just changing an Ext variable ? Something like:
Ext.setLocale("es");
ExtJs is not able to do this natively.
In my application I have solved this by defining a language class that works similar to gettext.
This allows me to have the code base in the default language with every string wrapped in the function Lang._('My text'). The translation is then done independently of ExtJs (In my case the translation interface is written in ExtJs, but the translation itself is independent).
I still cannot change the language dynamically. For this, I need to rerender the application in the browser. In my case, the translations are compiled into app.js, and therefore there is no need to reload app.js from the server.
I have only two languages, so this approach is OK. If you need to support many language, the best way is to load the translation string before rendering the application. To switch the language, you need then to load the translation and rerender the UI.
There is a good article about this on Saki's ExtJs site.

Use code to find another translation of a DNN page to link to the correct language

i have a list view with a link to the detail view with 2sexycontent.
at the list view i created a tag for the link with href="#Content.Link"
this works for german, but at the other 4 languages i have a problem with the localization. cause the tabs have differet links and at the moment all the details links get redirected to the german detail view.
how can i find the link to the corresponding DNN page with the other language using the standard DNN API?
thanks
regards
michael
There are two options
in the entity translations, specify the other page (probably not sexy)
look up the dnn-page which is the translated one of the page you have
I believe you want to do #2. I don't have the code snippet for that at hand, but it should be easy to find it in google or stack-overflow. Just ask for "How to find a translated page in server code" or something like that. Would be great if you share the result.

Internationalization and Localization in CakePHP 2.1

I am building a dual language app in CakePHP 2.1.x because of the great reviews of Cake's "built-in" localization features. However, I am wrestling with getting this powerful feature to work.
I know that this topic has been tackled for previous versions of Cake (here, here, here, and here), but it hasn't been solved for Cake 2.x. I am also referencing these articles in the cookbook (yes, I've read the manual):
http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html
http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html
Couple of things -- I do not want to do separate subdomains for each language. Instead, I prefer URL based language switching with the click of a button (in this case, a flag icon). The site will be actively maintained, so the content needs to update dynamically. Asking the client to maintain two separate sites/databases is out of the question.
I have Translate behavior set up for my PostModel, but I can't tell if it's working. I also initialized I18n by running I18n in the console, have confirmed the database tables exist, have set up my .po files, and have wrapped all my content in __(). However, when I change the default language in my browser to French, the site remains in English.
I've tried the P28n Component, but I think it's outdated for Cake 2.x. I also tried URL-based language switching based on this nuts-and-bolts-of-cakephp article, but apparently it's incompatible with the new CakePHP API.
Can anyone point me in the direction of a tutorial or instructions that work with CakePHP 2.x? One not already referenced here?
Update: I found this article: http://www.localizingjapan.com/blog/2011/11/10/localizing-a-cakephp-application/comment-page-1/#comment-7467. Does anyone know where you place the code for CakeSession::write('Config.language', 'fre'); and setlocale("LC_ALL", "fr_FR.utf8");?
Simply put the code in AppController::beforeFilter() and set the values based on however you retrieve the language, from a post request or a part of the URL.

Resources