Stack Overflow offers some "similar" questions but none of them is suitable unfortunately. Or I am a bad searcher.
There is the language
column in MySQL database which stores different ISO 639-1 codes depending on the user settings. Then I grab the user's ISO 631-1 code into the $lang
variable and can output it with echo
. No problem.
Is there a PHP 7 compatible technique to convert en
into English, es
into Español, fr
into Français, etc?
I'm currently using the following code to achieve this
if($lang == 'en'){$userlang = 'English';}
if($lang == 'es'){$userlang = 'Español';}
if($lang == 'fr'){$userlang = 'Français';}
which I don't find optimal as there is a huge list of ISO 639-1 codes and I definitely don't want to put them all into the code.
Found locale_get_display_script manual at php.net but it returns nothing even copypasted from a given example - may be my ISP doesn't provide all required libraries. So I can't even check if it is what I am looking for. Anyway it doesn't look like this function can get ISO 639-1 codes.
source https://stackoverflow.com/questions/69002935/convert-iso-639-1-into-a-language-name-in-local-language-with-php
Comments
Post a Comment