netcoding Posted February 9, 2010 Share Posted February 9, 2010 I have a question that I hope someone can help me. I have many text strings (more than 200 items) defined in a few language files. Here is an example. file_english.php text1 = "this is text 1 in English"; text2 = "This is text 2 in English"; file_spanish.php text1 = "this is text 1 in Spanish"; text2 = "this is text 2 in Spanish"; file_french.php text1 = "this is text 1 in French"; text2 = "this is text 2 in French"; When an url is processed, the code determines the "user language" (e.g. English) and imports the appropriate file. So the web pages will be in English. However, on one page, a user can select a different language (e.g. Spanish) in a drop down. When the user clicks the submit button, the following page will display SOME text in Spanish, but the rest of the page (including the page title) is still in English. Here is the question. I would like to selectively override a few variables from different files in the code to display those text in a different language. Is that possible? Any help is much appreciated. SS Link to comment https://forums.phpfreaks.com/topic/191491-overriding-selected-variables-with-file-imports/ Share on other sites More sharing options...
Fadion Posted February 10, 2010 Share Posted February 10, 2010 Are you importing those files using PHP's file manipulation functions? Why not declare those (text1, text2) as variables, include the file and reassign the variables you need to change a value? Link to comment https://forums.phpfreaks.com/topic/191491-overriding-selected-variables-with-file-imports/#findComment-1009842 Share on other sites More sharing options...
alexjb Posted February 10, 2010 Share Posted February 10, 2010 If you reload the entire page, shouldn't it just include the Spanish file? Personally, I'de go against manually overwriting particular strings if possible. Link to comment https://forums.phpfreaks.com/topic/191491-overriding-selected-variables-with-file-imports/#findComment-1009844 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.