有什么工具可以用来执行 pseudolocalization在 ASP.NET MVC 应用程序(使用 Razor View 引擎)上以帮助本地化测试?
最佳答案
我写了一个小实用程序,可以让我将文本转换为“伪文本”。
它基于一个简单的函数,该函数查看字符串中的每个字符。如果字符IsAlpha然后我给它添加一个重音。
我通过在字符后面附加 random diacritic mark between U+0300 and U+036F 来添加重音符号(变音符号范围)。
所以现在我只是本地化我的应用程序/网站,就像我是讲荷兰语的本地化人员之一一样。
ỉ w͝rͨo͡t̮e̤ a͈͟ s̏m͈a͞l̪lͅ u͇t̽i̡l̔i͜țy̭ a͟p̉p͕ t̼h̥aͤt̖͊ l͊e̗t̘s̈́ m̶eͭ c͟o̙n̚v̈e̲r̓t̝ t͌e̽x̳t͈ i̍n̔t̖o̺ "p̪̜s̔e̊u̟d̮o̱".
I͔t͒'sͪ b̞aͧs̜e̋dͫ o̸͚n͙ a̼ s̼i̥m̢ͫpͫl͗e̺ f̙uͪn͎̉c͙t͒ḯo̾n̑ w̰h̙i̷c͟ḣ̌ l̼óoͦk͔s͑ a̬t̆ e̓a̔c̈hͭ c̚h̻a̿r̴aͭc̤t̙eͦŗ͉ i̞n̴ t̀h̸e̮ͫ s̖t͘r͕i͇n͒g̴͐. I̳fͣ t̰ĥe̿ c͋h͡a͖r̸a̸c̟t̼e̞rͪ Ìs̀A̒l͒p̷h̗a̲ ţh̽e͚nͥ i̡ a̰d͙d̬ a̅n̊ a̐c̒c̒e̤͞n̜t̽ t̆o͑ i̴tͪ.
i̋ a̸d̋d́ a̰n̏ a͛c͏c̣͗e̾n͡t̎ b̷̞ẏ a̐p͞p̧͔eͩn͊ḍ͋ín̓g͚ t̬h͚ẹ ćh̞a͗ŗa͖c͐t̊e̷rͅ w͙iͩt̮hͮ a͡ r͙a͋nͅd̃o͞m̚ dͬi̠a͚c̸r̾iͩt͖i͋c̭ m̓ḁr̵k̡ b̞ë́t̼w̓e̬ë́n̨ U̵+0300 a̢n͙d͜ U͕+036F͓ (t̯͉hͪ͟eͮ d͓i͉aͣc͕̬r͜i͒t́i͓c̯a͚l̼ m̓a̅r̝̜k͎s̯ r͋ăn̪̒g̟e̱̮).
还有一个选项可以为文本添加填充,因此允许其他语言使用与英语不同的空间量
今天
->[T̀oͨd̼a͈̹y̭ !!]
控制面板
->[C̊ȍńt̪r͗o͂l͇ P̈ȁñeͮl͢ !!!!!]
氧化脱碳
->[Ŏx͞y̠dͥa͂t̿i̚v͙eͪ D̼e̖c̿ͤr͖b̐o̼x̹i͂l͖a̠t̮i̓o̧n̰ !!!!!!!]
还有我的PsuedoLocalizeText
函数:
function TForm1.PsuedoLocalizeText(s: WideString; AddPadding: Boolean): WideString;
var
i: Integer;
sb: TWideStringBuilder;
x: Integer;
tiny: WideString;
const
n: WideString = ''; //n=nothing
begin
//Code is public domain. No attribution required.
sb := TWideStringBuilder.Create;
try
for i := 1 to Length(s) do
begin
//http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/list.htm
//U+0300 .. U+36F are combining diacritic marks
x := $300+Random($36f-$300);
if Windows.IsCharAlphaW(s[i]) then
begin
tiny := n+ s[i] + WideChar(x);
if Random(10) < 1 then
tiny := n+tiny+WideChar($300+Random($36f-$300));
sb.Append(tiny);
end
else
sb.Append(s[i]);
end;
Result := sb.ToString;
finally
sb.Free;
end;
if AddPadding then
begin
Result := '['+Result+' ';
for i := 1 to Ceil(Length(s) / 3) do
begin
Result := n+Result+'!';
end;
Result := Result+']';
end;
end;
更新我的伪定位器:
我的下一个任务是让它在 *.resx
上运行,但排除 *.xx-yy.resx
,这样它也可以在 WinForms 应用程序上运行。
当然还要填写大小、属性,为文件夹获取正确的图标。
然后也许让它突出显示文件名的 fr-FR
或 qps-ploc
部分。
关于ASP.NET MVC 伪本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7673529/