好的。我一直在網絡中尋找一種無頭痛的國際化方式。我終於找到了手段。包括在你的構建PARAMS的語言環境,以及這樣做-locale locale/{locale}
的事情,使他們成爲性的資源管理器文件(即:locale/en_GB/lang.properties
在src文件夾。)Flex國際化問題(在onCreationComplete中選擇區域設置)
問題:我似乎無法設置用戶對啓動區域。我得到「的LocaleID指數超出範圍」一些錯誤(這是奇怪的,因爲是的LocaleID基於字符串..?)
這部分工作正常:
<fx:Script>
<![CDATA[
// Shorthand resource management.
private function getLang(key:String):String
{ return resourceManager.getString(key, 'lang'); }
]]>
</fx:Script>
這部分不工作:
protected function creationCompleteHandler(event:FlexEvent):void
{
var locale:LocaleID = new LocaleID("en_GB");
trace(locale.getLanguage()); // en
trace(locale.getRegion()); // GB
trace(locale.name); // en-GB
if (!empty(saveData.data.lang)) // empty checks if str == null or trim(str).length == 0
locale = new LocaleID(saveData.data.lang);
this.setStyle("locale", locale);
}
當我設置的語言環境未拋出的實際的錯誤,但是當在UI對象試圖讓他們的價值觀。完整的錯誤消息如下:
RangeError: Property locale value [object LocaleID] is out of range
at flashx.textLayout.property::Property$/defaultErrorHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\property\Property.as:31]
at flashx.textLayout.property::Property/setHelper()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\property\Property.as:230]
at flashx.textLayout.formats::TextLayoutFormat/setStyleByProperty()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\formats\TextLayoutFormat.as:628]
at flashx.textLayout.formats::TextLayoutFormat/set locale()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\formats\TextLayoutFormat.as:1271]
at spark.core::CSSTextLayoutFormat()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\core\CSSTextLayoutFormat.as:75]
at spark.components::RichEditableText/updateStylesIfChanged()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\RichEditableText.as:3619]
at spark.components::RichEditableText/commitProperties()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\RichEditableText.as:2491]
at mx.core::UIComponent/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:813]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]
有趣的事實: 1.我的名字是不是牛皮紙 2.我的SDK是不是E:\dev\4.5.1
......這是在C:\Program Files\Adobe\Adobe Flash Builder 4.5.1\sdks\4.5.1
(?)。好工作的錯誤信息!使用原來的構建路徑和所有...
存在堆棧跟蹤中顯示的構建路徑問題與構建框架SWC的方式有關。我認爲當你創建一個包含用於創建代碼提示的所有ASDoc和元數據的「FAT SWC」時,刪除這些開發路徑是不可能的。我對細節有些模糊;但這是我的理解。 – JeffryHouser
我設法以非常討厭的方式解決這個問題,所以我想我會寫出答案。我每天都越來越討厭Flex,因爲我看到Adobe做得太差了。 – cbroughton
作爲供參考,這些運行時錯誤是從textLayout框架生成的;而不是來自Flex框架代碼。我並不是說Flex就沒有問題;但你目前的錯誤不是其中之一。 – JeffryHouser