cssfreakie Posted March 18, 2011 Share Posted March 18, 2011 HI all, I know not much about php, but i thought before i start creating a nice application that is useful, i ask a bit around for advice. I was thinking that it could very well be smart to make something like a language file. In that file are for instance the names of table headers, error messages, button text etc. I thought that would be nice because that way i can easily translate a complete site, by using just one file, a language file. I thought i could use define() in that file to create some constants like: define("invalidname", "the name you provided is invalid"); Than In my index I include that file and use the constant in the right places. Now the question i have is, would this dramatically slow down my website or application, because it's loading the language file. Or is it a good approach. I really have no idea, but it seemed to me like a nice idea to separate standard stuff like errors, and button text instead of having to edit all files separately. Love to hear tips and advice, better methods on this. thanks Quote Link to comment https://forums.phpfreaks.com/topic/231016-a-multi-language-approach/ Share on other sites More sharing options...
johnny86 Posted March 18, 2011 Share Posted March 18, 2011 I wouldn't go and use definitions.. Here is a good article about localization in PHP: http://docstore.mik.ua/orelly/webprog/pcook/ch16_01.htm It's not by any means too comprehensive.. But there are atleast things I've found useful. Defining your languages to array is a basic easy-approach solution. But if you want performance, use gettext() or the alias _() and manage your language files through your command line or use something like Poedit to make it a little easier. Take a good look at internal php localization; setlocale(), date_default_timezone_set() combined with the right functions ie. time functions are very important to use to provide everyone information in their own national date/time format and weekday names etc etc. Like strftime() will create a date for you according to your locale. An article to set you up with using gettext: http://onlamp.com/pub/a/php/2002/06/13/php.html Poedit site: http://www.poedit.net/ Quote Link to comment https://forums.phpfreaks.com/topic/231016-a-multi-language-approach/#findComment-1189212 Share on other sites More sharing options...
cssfreakie Posted March 18, 2011 Author Share Posted March 18, 2011 oh wow, thanks alot m8, Every day I learn a new word. today its uml and localization. Great article i'll sure try to apply it, ty!! Quote Link to comment https://forums.phpfreaks.com/topic/231016-a-multi-language-approach/#findComment-1189218 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.