I have example language file en.php
<?php
$language = array(
"language_code" => "en",
"language_name" => "English",
);
These language files replace replace certain things in template files to support multi-language.
Is there a way to add stuff into the array using PHP?
So I do something in the settings, e.g. add a new language value and the PHP adds this to the file en.php and saves it.
I wonder if this is possible because it can be quite complicated I guess. If it is possible, a slight suggestion to do so would be appreciated. I don’t have much experience editing files in php.
If it would be better, I could change the language format to XML if that makes it easier.
Thanks
Instead of storing data in php code (or XML), use JSON. Load the data with:
and store it with:
If you really insist on storing your data as a php program, use the
var_exportfunction:There’s no need to use XML, since it would be slower and more complicated than JSON. Also, you should generally not store translations in a (relational) database, since the round trip time and repeated query parsing and evaluation are prone to slow down your application.