I made several websites and applications with support for several languages, where I used the XML language files and the keyword inside my code. For my web application, I find the method sucks. I love to read and understand my HTML code. This code makes no sense:
<h1><?= translate('main_headline'); ?></h1>
It looks good at the beginning, but only ends with unfortunate programmers, since the process of adding new functions now requires putting material into XML all the time.
My solution (I just wrote a simple PHP test parser an hour ago, do you think this will work on a large-scale project?)
I use English as the base language, and my source file looks like this:
<h1>{{ I love colors }}</h1>
My parser will use text (real text) as the key for the dictionary array. In this example, I translated from English English to English English.
$dictionary['I love colors']['en_GB'] = 'I love colours'
My dictionary does not require a dictionary, as it is already in the source file.
It has much more than a cache, backups, dictionary storage, etc. Do you think he will work in large projects? Is there something I did not consider?
source
share