开发者

PHP: How to add Languages layer to MVC framework?

开发者 https://www.devze.com 2022-12-13 04:32 出处:网络
I am currently working on my own implementation of a MVC framework. I would like to know how to add language layer to my 开发者_如何学JAVAframework so that it could support multiple languages other th

I am currently working on my own implementation of a MVC framework. I would like to know how to add language layer to my 开发者_如何学JAVAframework so that it could support multiple languages other than english. What's the role of unicode in this case?


Frameworks frequently utilize a concept of "localization files" (.po files as a standard) to do UI translation. In your view and controllers, whenever you want to show a piece of text, instead of calling

echo "Hello"

You'd do

echo MyFramework::Translate("Hello")

That Translate() function just looks up the right .po file, and based on the passed in "ID" of the phrase, returns the desired localized text.

0

精彩评论

暂无评论...
验证码 换一张
取 消