mirror of
https://github.com/zxing/zxing.git
synced 2024-11-13 14:34:08 -08:00
1. Set up all strings in res/*/strings.xml rather than as string
literals. 2. Using a very handy script for this purpose, and checking it into utils/ since it saved me some headache. 3. Turned tabs -> spaces for WifiResultHandler. 4. Better error handling on network types: look for exact matches rather than substrings. git-svn-id: https://zxing.googlecode.com/svn/trunk@1456 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
c2e3604aea
commit
c003d96b89
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">مشاركة عبر الرمز الشريطي</string>
|
<string name="share_name">مشاركة عبر الرمز الشريطي</string>
|
||||||
<string name="title_about">إصدار ماسح الرمز الشريطي</string>
|
<string name="title_about">إصدار ماسح الرمز الشريطي</string>
|
||||||
<string name="wa_name">التكوين اللاسلك</string>
|
<string name="wa_name">التكوين اللاسلك</string>
|
||||||
|
<string name="wifi_changing_network">تغيير الشبكة</string>
|
||||||
|
<string name="wifi_creating_network">إنشاء شبكة</string>
|
||||||
|
<string name="wifi_modifying_network">تعديل شبكة</string>
|
||||||
|
<string name="wifi_ssid_missing">اسم الشبكة مفقود</string>
|
||||||
|
<string name="wifi_type_incorrect">شبكة نوع غير صحيح</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Sdílet pomocí čárového kódu</string>
|
<string name="share_name">Sdílet pomocí čárového kódu</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Bezdrátová konfigurace</string>
|
<string name="wa_name">Bezdrátová konfigurace</string>
|
||||||
|
<string name="wifi_changing_network">Změna síť</string>
|
||||||
|
<string name="wifi_creating_network">Vytvoření sítě</string>
|
||||||
|
<string name="wifi_modifying_network">Úprava sítě</string>
|
||||||
|
<string name="wifi_ssid_missing">Název sítě chybí</string>
|
||||||
|
<string name="wifi_type_incorrect">Typ sítě nesprávné</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Del via stregkode</string>
|
<string name="share_name">Del via stregkode</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Wifi-forbindelse</string>
|
<string name="wa_name">Wifi-forbindelse</string>
|
||||||
|
<string name="wifi_changing_network">Ændring Network</string>
|
||||||
|
<string name="wifi_creating_network">Oprettelse af netværk</string>
|
||||||
|
<string name="wifi_modifying_network">Ændring Network</string>
|
||||||
|
<string name="wifi_ssid_missing">Netværk navn mangler</string>
|
||||||
|
<string name="wifi_type_incorrect">Netværk type forkert</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
|
@ -122,4 +122,9 @@
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Wifi konfiguration</string>
|
<string name="wa_name">Wifi konfiguration</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
|
<string name="wifi_changing_network">Ändern der Netzwerkeinstellungen</string>
|
||||||
|
<string name="wifi_creating_network">Erstellen Network</string>
|
||||||
|
<string name="wifi_modifying_network">Ändern Network</string>
|
||||||
|
<string name="wifi_ssid_missing">Netzwerk-Name fehlt</string>
|
||||||
|
<string name="wifi_type_incorrect">Netzwerk-Typ nicht korrekt</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Compartir por códigos de barras</string>
|
<string name="share_name">Compartir por códigos de barras</string>
|
||||||
<string name="title_about">Escáner de código de barras v</string>
|
<string name="title_about">Escáner de código de barras v</string>
|
||||||
<string name="wa_name">Configuración de la red</string>
|
<string name="wa_name">Configuración de la red</string>
|
||||||
|
<string name="wifi_changing_network">Cambio de la red</string>
|
||||||
|
<string name="wifi_creating_network">Creación de la Red</string>
|
||||||
|
<string name="wifi_modifying_network">Modificación de la Red</string>
|
||||||
|
<string name="wifi_ssid_missing">Nombre de la red desaparecidas</string>
|
||||||
|
<string name="wifi_type_incorrect">Red de tipo incorrecto</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Jaa viivakoodilla</string>
|
<string name="share_name">Jaa viivakoodilla</string>
|
||||||
<string name="title_about">Viivakoodin lukija v</string>
|
<string name="title_about">Viivakoodin lukija v</string>
|
||||||
<string name="wa_name">Langattoman yhteyden</string>
|
<string name="wa_name">Langattoman yhteyden</string>
|
||||||
|
<string name="wifi_changing_network">Vaihtaminen Verkko</string>
|
||||||
|
<string name="wifi_creating_network">Luominen verkoston</string>
|
||||||
|
<string name="wifi_modifying_network">Muuttaminen Verkko</string>
|
||||||
|
<string name="wifi_ssid_missing">Verkon nimi puuttuu</string>
|
||||||
|
<string name="wifi_type_incorrect">Verkon tyyppi virheellinen</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Partager par code barre</string>
|
<string name="share_name">Partager par code barre</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Configuration du réseau</string>
|
<string name="wa_name">Configuration du réseau</string>
|
||||||
|
<string name="wifi_changing_network">Changement de réseau</string>
|
||||||
|
<string name="wifi_creating_network">Création d\u0026#39;un réseau</string>
|
||||||
|
<string name="wifi_modifying_network">Modification du réseau</string>
|
||||||
|
<string name="wifi_ssid_missing">Le nom du réseau disparus</string>
|
||||||
|
<string name="wifi_type_incorrect">Réseau de type incorrect</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Megosztás vonalkóddal</string>
|
<string name="share_name">Megosztás vonalkóddal</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Hálózati konfiguráció</string>
|
<string name="wa_name">Hálózati konfiguráció</string>
|
||||||
|
<string name="wifi_changing_network">Változó Hálózat</string>
|
||||||
|
<string name="wifi_creating_network">Hálózat létrehozása</string>
|
||||||
|
<string name="wifi_modifying_network">Módosítása Hálózat</string>
|
||||||
|
<string name="wifi_ssid_missing">A hálózat neve hiányzik</string>
|
||||||
|
<string name="wifi_type_incorrect">Hálózati típusú hibás</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Condividi tramite codice a barre</string>
|
<string name="share_name">Condividi tramite codice a barre</string>
|
||||||
<string name="title_about">Scansione codice a barre v</string>
|
<string name="title_about">Scansione codice a barre v</string>
|
||||||
<string name="wa_name">Configurazione di rete</string>
|
<string name="wa_name">Configurazione di rete</string>
|
||||||
|
<string name="wifi_changing_network">Cambiare Network</string>
|
||||||
|
<string name="wifi_creating_network">Creazione di rete</string>
|
||||||
|
<string name="wifi_modifying_network">Modifica della rete</string>
|
||||||
|
<string name="wifi_ssid_missing">Nome della rete mancante</string>
|
||||||
|
<string name="wifi_type_incorrect">Tipo di rete non corretto</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">バーコードで共有する</string>
|
<string name="share_name">バーコードで共有する</string>
|
||||||
<string name="title_about">>QRコードスキャナー v</string>
|
<string name="title_about">>QRコードスキャナー v</string>
|
||||||
<string name="wa_name">ネットワーク構成</string>
|
<string name="wa_name">ネットワーク構成</string>
|
||||||
|
<string name="wifi_changing_network">ネットワークを変更する</string>
|
||||||
|
<string name="wifi_creating_network">作成ネットワーク</string>
|
||||||
|
<string name="wifi_modifying_network">ネットワークを変更する</string>
|
||||||
|
<string name="wifi_ssid_missing">ネットワーク名を欠いて</string>
|
||||||
|
<string name="wifi_type_incorrect">ネットワーク型不正</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Deel via barcode</string>
|
<string name="share_name">Deel via barcode</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Netwerkconfiguratie</string>
|
<string name="wa_name">Netwerkconfiguratie</string>
|
||||||
|
<string name="wifi_changing_network">Veranderen van Netwerk</string>
|
||||||
|
<string name="wifi_creating_network">Creating Network</string>
|
||||||
|
<string name="wifi_modifying_network">Het wijzigen van Netwerk</string>
|
||||||
|
<string name="wifi_ssid_missing">Netwerk naam ontbreekt</string>
|
||||||
|
<string name="wifi_type_incorrect">Netwerk soort onjuiste</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Udostępnij przez kod paskowy</string>
|
<string name="share_name">Udostępnij przez kod paskowy</string>
|
||||||
<string name="title_about">Skaner Kodów Paskowych v</string>
|
<string name="title_about">Skaner Kodów Paskowych v</string>
|
||||||
<string name="wa_name">Konfiguracja sieci</string>
|
<string name="wa_name">Konfiguracja sieci</string>
|
||||||
|
<string name="wifi_changing_network">Zmiana sieci</string>
|
||||||
|
<string name="wifi_creating_network">Tworzenie sieci</string>
|
||||||
|
<string name="wifi_modifying_network">Modyfikowanie sieci</string>
|
||||||
|
<string name="wifi_ssid_missing">Nazwa sieci brakuje</string>
|
||||||
|
<string name="wifi_type_incorrect">Typ sieci nieprawidłowe</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Partilhar por código de barras</string>
|
<string name="share_name">Partilhar por código de barras</string>
|
||||||
<string name="title_about">Scanner de código barras v</string>
|
<string name="title_about">Scanner de código barras v</string>
|
||||||
<string name="wa_name">Configuração de rede</string>
|
<string name="wa_name">Configuração de rede</string>
|
||||||
|
<string name="wifi_changing_network">Mudar Rede</string>
|
||||||
|
<string name="wifi_creating_network">Criação da rede</string>
|
||||||
|
<string name="wifi_modifying_network">Modificando Rede</string>
|
||||||
|
<string name="wifi_ssid_missing">Nome da rede em falta</string>
|
||||||
|
<string name="wifi_type_incorrect">Rede de tipo incorreto</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Поделиться через штрих-код</string>
|
<string name="share_name">Поделиться через штрих-код</string>
|
||||||
<string name="title_about">Сканер штрих-кодов версии </string>
|
<string name="title_about">Сканер штрих-кодов версии </string>
|
||||||
<string name="wa_name">конфигурации сети</string>
|
<string name="wa_name">конфигурации сети</string>
|
||||||
|
<string name="wifi_changing_network">Изменение сети</string>
|
||||||
|
<string name="wifi_creating_network">Создание сети</string>
|
||||||
|
<string name="wifi_modifying_network">Изменение сети</string>
|
||||||
|
<string name="wifi_ssid_missing">Сеть отсутствует имя</string>
|
||||||
|
<string name="wifi_type_incorrect">Тип сети неправильный</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Dela via streckkod</string>
|
<string name="share_name">Dela via streckkod</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Nätverkskonfiguration</string>
|
<string name="wa_name">Nätverkskonfiguration</string>
|
||||||
|
<string name="wifi_changing_network">Ändra Network</string>
|
||||||
|
<string name="wifi_creating_network">Skapa nätverk</string>
|
||||||
|
<string name="wifi_modifying_network">Modifiera nätverk</string>
|
||||||
|
<string name="wifi_ssid_missing">Nätverksnamn saknas</string>
|
||||||
|
<string name="wifi_type_incorrect">Nätverkstyp felaktig</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">通过条码分享</string>
|
<string name="share_name">通过条码分享</string>
|
||||||
<string name="title_about">条码扫描器</string>
|
<string name="title_about">条码扫描器</string>
|
||||||
<string name="wa_name">网络配置</string>
|
<string name="wa_name">网络配置</string>
|
||||||
|
<string name="wifi_changing_network">不断变化的网络</string>
|
||||||
|
<string name="wifi_creating_network">创建网络</string>
|
||||||
|
<string name="wifi_modifying_network">修改网络</string>
|
||||||
|
<string name="wifi_ssid_missing">网络实名失踪</string>
|
||||||
|
<string name="wifi_type_incorrect">网络类型不正确</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">通過條碼分享</string>
|
<string name="share_name">通過條碼分享</string>
|
||||||
<string name="title_about">條碼掃描器</string>
|
<string name="title_about">條碼掃描器</string>
|
||||||
<string name="wa_name">網絡配置</string>
|
<string name="wa_name">網絡配置</string>
|
||||||
|
<string name="wifi_changing_network">不斷變化的網絡</string>
|
||||||
|
<string name="wifi_creating_network">創建網絡</string>
|
||||||
|
<string name="wifi_modifying_network">修改網絡</string>
|
||||||
|
<string name="wifi_ssid_missing">網絡實名失踪</string>
|
||||||
|
<string name="wifi_type_incorrect">網絡類型不正確</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -121,5 +121,10 @@
|
||||||
<string name="share_name">Share via barcode</string>
|
<string name="share_name">Share via barcode</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="wa_name">Wifi Connection</string>
|
<string name="wa_name">Wifi Connection</string>
|
||||||
|
<string name="wifi_changing_network">Changing Network</string>
|
||||||
|
<string name="wifi_creating_network">Creating Network</string>
|
||||||
|
<string name="wifi_modifying_network">Modifying Network</string>
|
||||||
|
<string name="wifi_ssid_missing">Network name missing</string>
|
||||||
|
<string name="wifi_type_incorrect">Network type incorrect</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -39,11 +39,6 @@ import com.google.zxing.client.android.R;
|
||||||
*
|
*
|
||||||
* TODO(viki): Tell the user when the network is not available here
|
* TODO(viki): Tell the user when the network is not available here
|
||||||
* TODO(viki): Incorrect password, could not connect, give an error
|
* TODO(viki): Incorrect password, could not connect, give an error
|
||||||
* TODO(viki): Should never crash: crashes on S:ssid;P:pass;T:something;else;
|
|
||||||
* TODO(viki):
|
|
||||||
* TODO(viki):
|
|
||||||
* TODO(viki):
|
|
||||||
* TODO(viki):
|
|
||||||
*
|
*
|
||||||
* @author Vikram Aggarwal
|
* @author Vikram Aggarwal
|
||||||
*/
|
*/
|
||||||
|
@ -64,11 +59,11 @@ public class WifiActivity extends Activity {
|
||||||
|
|
||||||
// If the SSID is empty, throw an error and return
|
// If the SSID is empty, throw an error and return
|
||||||
if (setting.getSsid() == null || setting.getSsid().length() == 0) {
|
if (setting.getSsid() == null || setting.getSsid().length() == 0) {
|
||||||
return doError("SSID name missing");
|
return doError(R.string.wifi_ssid_missing);
|
||||||
}
|
}
|
||||||
// If the network type is invalid
|
// If the network type is invalid
|
||||||
if (setting.getNetworkType() == NetworkType.NETWORK_INVALID){
|
if (setting.getNetworkType() == NetworkType.NETWORK_INVALID){
|
||||||
return doError("Network type incorrect");
|
return doError(R.string.wifi_type_incorrect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the password is empty, this is an unencrypted network
|
// If the password is empty, this is an unencrypted network
|
||||||
|
@ -84,8 +79,8 @@ public class WifiActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int doError(String string) {
|
private int doError(int resource_string) {
|
||||||
statusView.setText(string);
|
statusView.setText(resource_string);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +102,7 @@ public class WifiActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int requestNetworkChange(WifiConfiguration config){
|
private int requestNetworkChange(WifiConfiguration config){
|
||||||
statusView.setText("Changing Network...");
|
statusView.setText(R.string.wifi_changing_network);
|
||||||
return updateNetwork(config, false);
|
return updateNetwork(config, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,15 +179,15 @@ public class WifiActivity extends Activity {
|
||||||
|
|
||||||
// TODO(vikrama): Error checking here, to ensure ssid exists.
|
// TODO(vikrama): Error checking here, to ensure ssid exists.
|
||||||
NetworkType networkT;
|
NetworkType networkT;
|
||||||
if (networkType.contains("WPA")) {
|
if (networkType.equals("WPA")) {
|
||||||
networkT = NetworkType.NETWORK_WPA;
|
networkT = NetworkType.NETWORK_WPA;
|
||||||
} else if (networkType.contains("WEP")) {
|
} else if (networkType.equals("WEP")) {
|
||||||
networkT = NetworkType.NETWORK_WEP;
|
networkT = NetworkType.NETWORK_WEP;
|
||||||
} else if (networkType.contains("nopass")) {
|
} else if (networkType.equals("nopass")) {
|
||||||
networkT = NetworkType.NETWORK_NOPASS;
|
networkT = NetworkType.NETWORK_NOPASS;
|
||||||
} else {
|
} else {
|
||||||
// Got an incorrect network type. Give an error
|
// Got an incorrect network type. Give an error
|
||||||
doError("Incorrect Network type: " + networkType);
|
doError(R.string.wifi_type_incorrect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,10 +224,10 @@ public class WifiActivity extends Activity {
|
||||||
private int updateNetwork(WifiConfiguration config, boolean disableOthers){
|
private int updateNetwork(WifiConfiguration config, boolean disableOthers){
|
||||||
int networkId;
|
int networkId;
|
||||||
if (findNetworkInExistingConfig(config.SSID) == null){
|
if (findNetworkInExistingConfig(config.SSID) == null){
|
||||||
statusView.setText("Creating network...");
|
statusView.setText(R.string.wifi_creating_network);
|
||||||
networkId = wifiManager.addNetwork(config);
|
networkId = wifiManager.addNetwork(config);
|
||||||
} else {
|
} else {
|
||||||
statusView.setText("Modifying network...");
|
statusView.setText(R.string.wifi_modifying_network);
|
||||||
networkId = wifiManager.updateNetwork(config);
|
networkId = wifiManager.updateNetwork(config);
|
||||||
}
|
}
|
||||||
if (networkId == -1 || !wifiManager.enableNetwork(networkId, disableOthers)) {
|
if (networkId == -1 || !wifiManager.enableNetwork(networkId, disableOthers)) {
|
||||||
|
|
68
android/utils/translate.py
Executable file
68
android/utils/translate.py
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2010 ZXing authors
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Translate a string from English to all locales used in the Barcode
|
||||||
|
# Scanner Android project
|
||||||
|
#
|
||||||
|
# Author: Neha Pandey
|
||||||
|
|
||||||
|
from urllib2 import urlopen
|
||||||
|
from urllib import urlencode
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def translate (in_lang, out_lang, input):
|
||||||
|
"""Translate the input from in_lang to out_lang using Google Translate"""
|
||||||
|
# Create the URL
|
||||||
|
langpair = '%s|%s' % (in_lang, out_lang)
|
||||||
|
base = 'http://ajax.googleapis.com/ajax/services/language/translate?'
|
||||||
|
params = urlencode ((('v',1.0),
|
||||||
|
('q',input),
|
||||||
|
('langpair',langpair),) )
|
||||||
|
url = base + params
|
||||||
|
# Call translation
|
||||||
|
content = urlopen(url).read()
|
||||||
|
|
||||||
|
# Snip out unwanted fluff from the translation
|
||||||
|
start_index = content.find('"translatedText":"') + 18
|
||||||
|
translation = content [start_index:]
|
||||||
|
end_index = translation.find('"}, "')
|
||||||
|
output = translation[:end_index]
|
||||||
|
return output
|
||||||
|
|
||||||
|
# All the languages to translate to
|
||||||
|
language_list = ['en', 'ar', 'cs', 'da', 'de', 'es',
|
||||||
|
'fi', 'fr', 'hu', 'it', 'ja', 'nl',
|
||||||
|
'pl', 'pt', 'ru', 'sv', 'zh-CN',
|
||||||
|
'zh-TW']
|
||||||
|
|
||||||
|
if (len(sys.argv) < 3):
|
||||||
|
print "Usage: %s name String to translate" % sys.argv[0]
|
||||||
|
print "Sample: %s ask-banana Give me a banana" % sys.argv[0]
|
||||||
|
import sys
|
||||||
|
sys.exit (-1);
|
||||||
|
|
||||||
|
# First argument is the name of the string
|
||||||
|
string_name = sys.argv[1]
|
||||||
|
# Remaining arguments is the string to be translated in English
|
||||||
|
input_string =' '.join(sys.argv[2:])
|
||||||
|
|
||||||
|
# Translate all languages
|
||||||
|
for i in range(len(language_list)) :
|
||||||
|
translation = translate ('en', language_list[i], input_string)
|
||||||
|
xml_string = '<string name="' + string_name + '">' + \
|
||||||
|
translation + '</string>'
|
||||||
|
print language_list[i], xml_string
|
||||||
|
|
Loading…
Reference in a new issue