PHP语言本地化 [英] Language localization in PHP

查看:115
本文介绍了PHP语言本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要评论我的网站本地化系统解决方案.

I need comments on my solution of a website localization system.

内容:

Field   Type    Null    Key Default Extra
id  int(11) NO  PRI NULL    auto_increment
Page    varchar(30) YES     NULL     
Locale  varchar(10) YES     NULL     
Data    longtext    YES     NULL

我的想法是将每个页面和每个区域设置存储到Content表中.例如:

My thought is to store each page and each locale into the Content table. For example:

index.php en_GB {data}
index.php de_DE {data}

数据"字段将由一个json_encoded数组组成,其中将存储每个页面元素的文本.例如:

The Data field would consist of a json_encoded array in which the text of each of the page elements would be stored. For example:

$data['Headline1'] = 'The Headline';
$data['Welcome'] = 'The welcome text.';

我尚未实现它,但我计划使用 memcached 来提高性能-从一点开始,我就知道这是使用它的理想数据,因为它不容易经常更新.

I have yet to implement it, but I plan on using memcached to improve performance - and from the little I know this is the perfect kind of data to use it on since it is not prone to be updated very often.

这是好事还是坏事,应该全部废弃吗?请发表评论!

Is this good or bad, should it all be scrapped? Comments please!

推荐答案

一些注意事项:

  1. 不要每页存储翻译,这会导致大量冗余数据,因为某些翻译会在多页中发生.
  2. 我建议不要将所有翻译都放入数据库的一个字段中,为每个翻译句子添加一个条目.
  3. 用无符号的tinyint替换语言环境(varchar)并在其上创建索引,请在语言环境表中使用语言环境.

类似的东西:

translationId | localeId | translationKey | translationText

这篇关于PHP语言本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆