• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make a normal translation for a site similar to Laravel

#1
A question for developers, you can implement the translation of the application in a similar manner as in Laravel so that you can call a simple function __ ('translation', parameter) from anywhere. Because it’s not very convenient to create arrays of translation, for example, how you implemented


PHP Code:
return [
   'commandNotFound' => 'Команда "{0}" не найдена.',
   'helpUsage'       => 'Использование:',
   'helpDescription' => 'Описание:',
   'helpOptions'     => 'Опции:',
   'helpArguments'   => 'Аргументы:',
   'invalidColor'    => 'Недопустимый {0} цвет: {1}.',
]; 



and do like this




PHP Code:
return [
    
'Uso:'          => 'Использование:',
    
'Descripción:'  => 'Описание:',
    
'Opciones:'     => 'Опции:',
    
'Argumentos:'   => 'Аргументы:',
    
'Inválido {0} color: {1}.'    => 'Недопустимый {0} цвет: {1}.',
]; 

and then call us like this __ ('Opciones:') anywhere
Reply

#2
There are many ways of implementing translations. In fact, in Laravel you can do it also in couple of ways.
You can always create a static helper class e.g TextHelper and based your translations provider call -> TextHelper::getText(translationKey)

In that sense I don't quite feel that need to create a special translation solution in CI.

I hope have understood your point correctly.
Reply

#3
(10-10-2019, 09:17 AM)milengardev1994 Wrote: There are many ways of implementing translations. In fact, in Laravel you can do it also in couple of ways.
You can always create a static helper class e.g TextHelper and based your translations provider call -> TextHelper::getText(translationKey)

In that sense I don't quite feel that need to create a special translation solution in CI.

I hope have understood your point correctly.
the problem is that there are no examples, ways to implement this, so I showed an example of how I did it in 3 versions. So I wrote my own version, I wanted the professionals to finalize it, maybe I did something wrong, can be done much better.
Reply

#4
I am interested with an exemple for translation.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.