How to use Laravel's Localization?

0

I have a question about using Laravel's Localization 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 translator.php 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 phrase contained in h2, do I have to translate word for word or do I have to translate the entire sentence at once?

    
asked by anonymous 25.06.2018 / 20:25

1 answer

0

Internationalization files or language-independent localization translates just what you have previously set up ... You could even translate word by word from the sentence, but output would not because it would not make sense.

Answering your question, you should rather write the sentence altogether:

<?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 you do not know if it will or will not exist I recommend using translation APIs because it is not worth developing something because to have a good result would have to apply machine learning which would cost much more than using something done by giant companies that already use this technology.

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

AWS Translate

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

    
25.06.2018 / 20:57