How to use Laravel Localization?

Asked

Viewed 164 times

0

I have a question to use the Localization of Laravel correctly, I have an application in Portuguese and I have to translate it into English.. my doubt is the following ex:

<h2>Isso será apenas um teste não fique bravo</h2>

I created a.php translator file inside the Resources/lang/en/translator.php folder, which has the following code:

    <?php 

    return [



    //**dúvida aqui**   Na documentação pede para criar um array com a palavra original sendo a chave e a tradução sendo o valor ex:

'apenas' => 'only' 




    ]

     ?>

As I have this sentence contained in H2, I have to translate word by word or I have to translate the whole sentence at once ?

1 answer

0


Files of internationalization or localization independent of the language translates only what you previously set up... You could even translate word by word of the phrase, however the output would not have quality because it would not make sense.

To answer your question, you should write the full sentence:

<?php 
    return [
'apenas' => 'only',
'Isso será apenas um teste não fique bravo' => 'This will only be a test. Do not be mad.' 
]

 ?>

For phrases that you do not know whether or not there will be I recommend using translation API’s because it is not worth you developing something because to have a good result would have to apply machine Learning what would cost much more than using something done by giant companies that already use that technology.

Google Translate API (They give you R $ 900,00 to test the cloud tools to use the translator for 1 year of good)

AWS Translate (Up to 2 Million characters per month for 1 year)

Microsoft Translator (Up to 2 Million characters per month for 1 year)

Browser other questions tagged

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