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

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

问题描述

我目前正在研究一个网站的本地化,这是一个首先在英文中。第三方公司进行了翻译,并为我们提供了一个Excel文件与翻译。哪个我成功转换为我可以在我的视图中使用的PHP数组。我正在使用Eclipse for Windows来编辑我的PHP文件。



除了我需要在字符串中添加变量,除了

 '%1现在关注%2'

在阿拉伯语中,我被提供了像这样的字符串:

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

我发现用%1和%2替换 _ _是非常困难的,因为阿拉伯语部分是左边的字符串的权利,%1 %2 将被视为从左到右,或从右到左,我不确定。我几乎没有按照我的参数顺序的结果,因为%1有时会在字符串左边,有时在右边,这取决于我开始输入的位置。复制粘贴替换字符串也可能具有相同的奇怪效果。



大多数时候,我最终都有一个像这样的字符串:

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

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



以前我确信有人是这个问题。有没有办法在Eclipse中轻松完成?还是使用更智能的编辑器来解决阿拉伯问题?或者也许是Windows的问题?有没有解决方法?



更新



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

 '%1'。 'آتتتبع'。 '%2'

更新2



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

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

如果没有找到其他解决方案,这可能是一个很好的选择。

解决方案

@Adnan帮助我意识到,后来证实了拉丁字母与阿拉伯语文本混合时有问题。



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



这显示了PHP文件中的预期结果,它很容易编辑:

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


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:

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

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

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.

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?

UPDATE

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

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

UPDATE 2

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 helped me realize and later confirmed that there are issues when mixing Latin numbers with Arabic text.

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}, ...

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

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

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

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