Welcome Guest, Not a member yet? Register   Sign In
Multi-language support - How to change language in the view?
#1

(This post was last modified: 06-01-2019, 01:29 AM by yamahdico.)

Hi!

I followed the instructions but cannot load languages in the view.
For example in page's result is shown 5 languages.

Example for one language lang('academic.article') but how we have do for 5 language?

Thanks all
Reply
#2

(This post was last modified: 06-01-2019, 08:16 AM by InsiteFX. Edit Reason: Added Localization section )

Create a CMS using CodeIgniter 3

Build multi language website in codeigniter.

CI 4 Has language built-in so it maybe a little different then CI 3.

SEE:

CodeIgniter 4 User Guide - Localization
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Thanks for your reply but I'm still having this issue. Exclamation
It is intended to display on one page five languages simultaneously in the view.

Idea for example "$request->setLocale('ru')". This command only works in the control.

We need to run this command or same code in the view for switch languages concurrently.
Reply
#4

Best simple way of doing it is to use google translate.

How TO - Google Translate
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(06-30-2019, 04:20 AM)yamahdico Wrote: Thanks for your reply but I'm still having this issue. Exclamation
It is intended to display on one page five languages simultaneously in the view.

Idea for example "$request->setLocale('ru')". This command only works in the control.

We need to run this command or same code in the view for switch languages concurrently.

All the “hard work” should be done in the controller, never in the view. It can be done in a model or library but the final result should be fetched by the controller and passed to the view. 

If you want to get the same language string in five different languages, you can call setLocale for each languages, get the translated text string and store the result in an array, and then pass this array of text to the view so it can be displayed in the HTML document or used in JavaScript.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#6

To display different currency, it is predesignated to be used in the view as the third parameter to the lang() method, but we want to return the string by the language key in many languages.

For example, similar to the currency as the third parameter:
https://codeigniter4.github.io/userguide...ing-locale
Reply
#7

Can't you pass the the locale for the language you want as the third param of the `lang()` calls and get the results you want?

Code:
echo lang('foo.bar', [], 'en');
echo lang('foo.bar', [], 'fr');
Reply




Theme © iAndrew 2016 - Forum software by © MyBB