I’m building some software and want to implement internationalization into it and have been reading the docs in Yii2 on how to do it, but my question is…
Is it suggested to build your first language files along with it when you do each piece of text? …or I guess you could just do a search files at a later stage to find all instances of code that needs translation and then make up your language file.
I only ask because I’ve never done anything like this before and the source language / locale we are using is ‘en-US’; I guess I could do up a language file for ‘en-GB’ along the way which will make getting translations done for other languages much easier.
…or do people generally just make a language file for the source language anyway such as languages files for ‘en-US’?
It is recommended to use English for the messages in code, you do NOT need translation files for these because they will not change from English to English. You can run a Yii command to extract all the messages once you have finished the site. It will search for Yii::t()
Open a (windows) console go to the root of the site and type following command: