Asp.net

ASP.NET MVC 偽本地化

  • January 15, 2016

是否有任何工具可用於在 ASP.NET MVC 應用程序(使用 Razor 視圖引擎)上執行本地化以幫助進行本地化測試?

本文的下載中有一個“偽程序”工具:http: //msdn.microsoft.com/en-us/magazine/cc163991.aspx

如果你很懶,它包括原始碼(winforms)和二進製文件

我寫了一個小實用程序,讓我可以將文本轉換為“偽”。

它基於一個查看字元串中每個字元的簡單函式。如果字元IsAlpha然後我添加一個重音到它。

我通過在 U+0300 和 U+036F(變音符號範圍)之間附加帶有隨機變音符號的字元來添加重音。

在此處輸入圖像描述

所以現在我只是本地化我的應用程序/網站,就像我是說荷蘭語的本地化人員之一一樣。


W͝rͨo͡t̮e̤ a͈͟ S̏m͈a͞l̪lͅlͅ u͇t̽l̔i͜țy̭y̭ a͟p͕p͕ t̼h̥aͤt̖͊t̖͊t̘s̈s̈S̈́ m Chinese

i͔t͒’sͪb̞aͧs̜s̜s̜ 我̳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̱̮).


還有一個選項可以為文本添加填充,因此允許其他語言不使用與英語相同的空間

  • Today->[T̀oͨd̼a͈̹y̭ !!]
  • Control Panel->[C̊ȍńt̪r͗o͂l͇ P̈ȁñeͮl͢ !!!!!]
  • Oxydative Decarboxilation->[Ŏx͞y̠dͥa͂t̿i̚v͙eͪ D̼e̖c̿aͤ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, 但 exclude*.xx-yy.resx上工作,這樣它也可以在 WinForms 應用程序上工作。

當然,填寫大小屬性,為****文件夾獲取正確的圖示。

然後也許讓它突出顯示文件名的一部分fr-FRqps-ploc部分。

引用自:https://stackoverflow.com/questions/7673529