4
A
回答
5
我發現這個使用javascript的解決方案。這是因爲GWT不支持Collator。
http://osdir.com/ml/GoogleWebToolkit/2009-06/msg01572.html
public class Collator {
public static final Collator getInstance() {
return instance;
}
private static final Collator instance = new Collator();
public native int compare(String source, String target); /*-{
return source.localeCompare(target);
}-*/
}
我從來沒有使用過個人,但它看起來很有希望。 您可能需要進行更改才能確保沒有跨瀏覽器問題。
編輯:
閱讀JSNI。
這允許GWT在你的Java代碼中調用原始的「javascript」代碼。這就是我們在上述課堂上所做的。 「比較」方法使本地調用javascript。
http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#writing
將Collator.java添加到您當前的工作空間。
您應該能夠比較如下。
Collator customCollator = Collator.getInstance();
if (customCollator.compare(srcString , targetString) > 0)
{
//the compare method will return an int.
// write your code here.
}
希望這會有所幫助。
0
最簡單的方法是將locale屬性添加到常量類。
我有的像這樣
import com.google.gwt.i18n.client.Constants;
public interface GeneralConstants extends Constants {
@DefaultStringValue("de")
String locale();
定義的GeneralConstants類在每一個常量I類可以繼承的語言環境,我可以把它在每一種語言很容易地定義
知道我是什麼樣的語言環境。我只是叫屬性
private static GeneralConstants c = GWT.create(GeneralConstants.class);
...
formData.getForm().getName(c.locale())
還有一種方式來獲得當前設置的語言環境,但我不記得:-)
+2
這對字符串比較有幫助嗎? – Smalcat 2013-04-30 10:15:09
相關問題
- 1. 如何比較英文環境中的中文字符串?
- 2. Javascript - 比較字符串環境
- 3. GWT:語言環境不變?
- 4. GWT DatePicker語言環境
- 5. GWT語言環境變化
- 6. 更改字符串語言環境
- 7. 比較兩種語言字符串
- 8. 字符串比較困境
- 9. 如何從字符串中選擇語言環境
- 10. 如何比較依賴語言環境的浮點數?
- 11. 如何解析日期包含語言環境的字符串
- 12. Android:如何在特定語言環境中獲取字符串而不更改當前語言環境
- 13. GWT添加新的語言環境,undefined.cache.js
- 14. 在C編程語言中比較鏈表中的字符串
- 15. Rails I18n語言環境的字符串中的操作
- 16. 如何使用FastGettext將一個字符串從一個語言環境轉換爲另一個語言環境?
- 17. 如何使用LocaleInfo獲取GWT中的當前語言環境
- 18. 驗證Golang中的語言環境字符串
- 19. 將日期轉換爲Windows中語言環境的字符串
- 20. 從特定於語言環境的字符串中獲取NSDecimalNumber?
- 21. GWT:字符串比較不工作
- 22. for循環中的字符串比較
- 23. 停用語言環境Unicode字符
- 24. 在Java中排序多語言環境字符串
- 25. FLEX - 在ActionScript中設置條件語言環境字符串
- 26. 來自GregorianCalendar的基於語言環境的日期字符串
- 27. 如何從Java的字符串表示中獲取語言環境?
- 28. 如何在PHP中過濾基於語言環境的驗證字符串?
- 29. 如何比較字符串
- 30. 如何比較字符串
我發現它也,但我不知道如何使用它;/ – Samoth 2011-05-30 10:30:13
@Samoth希望幫助。編輯我的回答 – 2011-05-30 12:37:03
是的,它幫助我:)謝謝! – Samoth 2011-05-30 12:56:57