1
0
forked from GitHub/gf-core

Towards looking at the locale for default language. Added flag icons.

This commit is contained in:
bjorn
2008-09-17 10:12:36 +00:00
parent 04e3c06aec
commit 64bbd08edd
251 changed files with 49 additions and 8 deletions

View File

@@ -36,6 +36,16 @@ public class GF {
public static class Languages extends JsArray<Language> {
protected Languages() { }
public final Language getLanguage(String name) {
int c = length();
for (int i = 0; i < c; i++) {
Language l = get(i);
if (l.getName().equals(name))
return l;
}
return null;
}
}
public static class Language extends JavaScriptObject {

View File

@@ -22,6 +22,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.i18n.client.LocaleInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -34,14 +36,19 @@ public class Translate implements EntryPoint {
private CompletionOracle oracle;
private SuggestBox suggest;
private GF.Languages availableLangs;
private List<String> fromLangs;
private List<String> toLangs;
private VerticalPanel outputPanel;
private Label statusLabel;
private void addTranslation(String text) {
private void addTranslation(String text, String toLang) {
Label l = new Label(text);
l.addStyleName("my-translation");
GF.Language lang = availableLangs.getLanguage(toLang);
if (lang != null) {
l.getElement().setLang(lang.getLanguageCode());
}
outputPanel.add(l);
}
@@ -51,7 +58,7 @@ public class Translate implements EntryPoint {
outputPanel.clear();
for (int i = 0; i < translations.length(); i++) {
GF.Translation t = translations.get(i);
addTranslation(t.getText());
addTranslation(t.getText(), t.getTo());
}
}
public void onError (Throwable e) {
@@ -155,6 +162,7 @@ public class Translate implements EntryPoint {
gf.languages(new GF.LanguagesCallback() {
public void onResult(GF.Languages languages) {
availableLangs = languages;
for (int i = 0; i < languages.length(); i++) {
GF.Language l = languages.get(i);
if (l.canParse()) {
@@ -162,14 +170,15 @@ public class Translate implements EntryPoint {
}
toLangBox.addItem(l.getName());
}
setStatus("Loaded languages.");
setStatus("Loaded languages.");
}
public void onError (Throwable e) {
showError("Error getting language information", e);
}
});
GWT.log("Current locale: " + LocaleInfo.getCurrentLocale().getLocaleName(), null);
}
}

View File

@@ -15,9 +15,22 @@
}
.my-translation {
border-width: 0 0 0 0;
border-style: solid;
border-color: silver;
padding: 0.2em;
margin: 0.2em;
padding-left: 25px;
font-size: 150%;
background-repeat: no-repeat;
background-position: 0% 50%;
}
* [LANG=bg] { background-image: url("flags/bg.png"); }
* [LANG=ca] { background-image: url("flags/catalonia.png"); }
* [LANG=da] { background-image: url("flags/dk.png"); }
* [LANG=de] { background-image: url("flags/de.png"); }
* [LANG=en] { background-image: url("flags/gb.png"); }
* [LANG=fi] { background-image: url("flags/fi.png"); }
* [LANG=fr] { background-image: url("flags/fr.png"); }
* [LANG=it] { background-image: url("flags/it.png"); }
* [LANG=no] { background-image: url("flags/no.png"); }
* [LANG=ru] { background-image: url("flags/ru.png"); }
* [LANG=es] { background-image: url("flags/es.png"); }
* [LANG=sv] { background-image: url("flags/se.png"); }

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Some files were not shown because too many files have changed in this diff Show More