使用 Eclipse 处理 PHP 中的阿拉伯字符串 [英] Handle arabic string in PHP with Eclipse

查看:27
本文介绍了使用 Eclipse 处理 PHP 中的阿拉伯字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在对网站进行本地化,该网站最初仅提供英文版本.第三方公司进行了翻译,并为我们提供了带有翻译的 excel 文件.我成功地将其转换为可以在我的视图中使用的 PHP 数组.我正在使用 Eclipse for Windows 来编辑我的 PHP 文件.

I am currently working on the localization of a website, which was first in english only. A third party company did the translations, and provided us with an excel file with the translations. Which I successfully converted to a PHP array that I can use in my views. I'm using Eclipse for Windows to edit my PHP files.

一切都很好,只是我需要在我的字符串中添加变量,例如:

All is fine, except that I need to add variables in my strings, ex:

'%1 is now following %2'

在阿拉伯语中,我得到了这样的字符串:

In arabic I was provided with strings like this one:

'_______الآن يتتبع _______'

我发现用 %1 和 %2 替换 __ 非常困难,因为阿拉伯语部分是从右到左的字符串,而 %1%2 将被视为从左到右或从右到左,我不确定.我的参数顺序几乎没有我期望的结果,因为 %1 有时会在字符串的左侧,有时在右侧,具体取决于我开始输入的位置.复制粘贴替换字符串也会产生同样奇怪的效果.

I find that replacing __ with %1 and %2 is incredibly difficult because the arabic part is a right to left string, and the %1, %2 will be considered left-to-right, or right-to-left, and I'm not sure . I hardly have the results I expect with the order of my param, because %1 will sometimes go to the left of the string, sometimes on the right, depending on where I start to type. Copy-pasting the replacement strings can also have the same strange effects.

大多数时候我会得到这样的字符串:

Most of the times I end up with a string like this one:

%2الآن يتتبع %1

%1 应该在右手边的站点,%2 应该在左手边的站点上.%1 显然被认为是从右到左的字符串,因为 % 出现在右侧.%2 被认为是从左到右.

The %1 should be at right hand site, the %2 at the left hand site. The %1 is obviously considered right-to-left string because the % appears on the right. The %2 is considered left-to-right.

我敢肯定之前有人遇到过这个问题.有什么方法可以在 Eclipse 中轻松完成吗?或者使用更智能的编辑器处理阿拉伯语问题?或者可能是 Windows 问题?有解决方法吗?

I'm sure someone as this issue before. Is there any way it can be done easily in Eclipse? Or using a smarter editor for arabic issues? Or maybe it is a Windows issue? Is there a workaround?

更新

我也尝试将我的字符串拆分成多个字符串,但这也改变了参数的顺序:

I also tried splitting my string into multiple strings, but this also changes the order of the parameters:

'%1' . 'الآن تتبع' . '%2'

更新 2

似乎更改替换字符串会使事情变得更好.它可能与阿拉伯字符串中数字的处理方式有关.这个字符串在 Eclipse 中编辑没有任何问题.参数顺序正确,字符串被PHP正确处理:

It seems that changing the replacement string makes things better. It is probably linked to how numbers are handled in Arabic strings. This string was edited in Eclipse without any problem. The order of the parameter is correct, the string is handled correctly by PHP:

'{var2} الآن يتتبع {var1}'

如果找不到其他解决方案,这可能是一个不错的选择.

If no other solution is found, this could be a good alternative.

推荐答案

@Adnan 帮助我意识到,后来确认将拉丁数字与阿拉伯文本混合时存在问题.

@Adnan helped me realize and later confirmed that there are issues when mixing Latin numbers with Arabic text.

基于该结论,解决方案只是停止使用 %1%2%3、...作为占位符.我将使用更具描述性的关键字,例如 {USER}{ALBUM}{PHOTO}、...

Based on that conclusion, the solution is simply to stop using %1, %2, %3, ... as placeholders. I will be using more descriptive keywords instead, for example {USER}, {ALBUM}, {PHOTO}, ...

这显示了 PHP 文件中的预期结果,并且很容易

This shows the expected result in the PHP file and it is easily editable:

'ar' => '{USER} الآن يتابع {ALBUM}'

这篇关于使用 Eclipse 处理 PHP 中的阿拉伯字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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