How do I make a translation system in PHP and keep the translation when switching pages?

Asked

Viewed 275 times

0

Well, I am in need of a translation system via PHP, however, I wish to be translated the link looks like this: www.meudominio.com.br/en or www.meudominio.com.br/en at the same time that it will save the type of language, I want it to be able to enter other pages, getting more or less like this: www.meudominio.com.br/en/Register or www.meudominio.com.br/en/registro Regarding the translation of the link, I know how to do this, but I wish this style of system, if you know how I can do help me. I’ve searched the net, but I only find old systems that don’t work.

1 answer

0


There are several ways of doing translation, one of them is using database and referencing the word for each of the languages.

The other way would be to store in a text file.

Which one should I use? It depends on your project, see Wordpress, does not use the bank to translate your system.

Inside your question there are 2 problems, not 1 only, try to unlock as much as possible.

  1. translate
  2. Routing.

I suggest you research more about routing and try to learn as much as you can, the language change is a matter of route parameter, when identifying the parameter of that request, you pass the translation you like.

  • Well, thanks for the comment. But, I found a good way to do the translation and routing at the same time. I performed with a function, getting the return of the array like this: Return ((!$langueSelect[$langueVisist]) ? $langueSelect['en'][$scopoTranslate] : $langueSelect[$langueVisist][$scopoTranslate]); will search in the function if there is translation, if there is not, it defines the language 'EN' as the main of the website, of course the structure of the site, I am doing a translation at a time, already in relation to texts, I will go by one with AJAX pulling from your language.

  • If you ask me how do pro 'Languevisist' catch the visitor’s language, I use: 'substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0,2)', then my function was: <?php echo $Langue->scopeLangue(BASELANGUE, 'login-connect'); ? >, rs :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.