Skip to content

Commit

Permalink
Merge pull request #87 from huttneab/spanish_translation
Browse files Browse the repository at this point in the history
Add spanish translations
  • Loading branch information
huttneab authored Aug 27, 2016
2 parents 94d6c11 + eee49f5 commit fbde7ef
Show file tree
Hide file tree
Showing 13 changed files with 384 additions and 90 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 9
def versionMinor = 1
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.

apply plugin: 'com.android.application'
Expand Down
8 changes: 4 additions & 4 deletions app/src/internalDebug/res/values/debug_strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>
<string name="development_settings">Development Settings</string>
<string name="debug_drawer_network_endpoint_description">Enter the URL of the server to which you want to connect.\n\ne.g., https://bob-loblaw.local/1.0/</string>
<string name="debug_drawer_network_proxy_description">Enter the host of the server through which you want to proxy.\n\ne.g., 12.34.56.78:9000</string>
<string name="debug_drawer_welcome">Debug settings are available in this drawer.</string>
<string name="development_settings" translatable="false">Development Settings</string>
<string name="debug_drawer_network_endpoint_description" translatable="false">Enter the URL of the server to which you want to connect.\n\ne.g., https://bob-loblaw.local/1.0/</string>
<string name="debug_drawer_network_proxy_description" translatable="false">Enter the host of the server through which you want to proxy.\n\ne.g., 12.34.56.78:9000</string>
<string name="debug_drawer_welcome" translatable="false">Debug settings are available in this drawer.</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/internalDebug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="tos_text_blurb">Lorem ipsum dolor sit amet, aperiri gubergren voluptatibus ea vis.
<string name="tos_text_blurb" translatable="false">Lorem ipsum dolor sit amet, aperiri gubergren voluptatibus ea vis.
Harum nullam referrentur no vel. Partem saperet appellantur nec id. Malis latine vituperata
at cum.Duo tota ceteros inimicus id, est te oblique consulatu complectitur, id dolor iuvaret
consequuntur usu. Scripta iuvaret repudiare eam te, usu prima inciderint ex. Ad eum eirmod
Expand Down
4 changes: 2 additions & 2 deletions app/src/internalDebug/res/values/titles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="application_name">Grommet Sample Internal Debug</string>
<string name="launcher_name">Grommet Internal (D)</string>
<string name="application_name" translatable="false">Grommet Sample Internal Debug</string>
<string name="launcher_name" translatable="false">Grommet Internal (D)</string>
</resources>
25 changes: 19 additions & 6 deletions app/src/main/java/com/rockthevote/grommet/data/db/model/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.rockthevote.grommet.util.Strings;
import com.squareup.sqlbrite.BriteDatabase;

import java.util.Locale;

import rx.functions.Func1;

@AutoValue
Expand Down Expand Up @@ -202,24 +204,35 @@ public static Suffix fromString(String suffix) {
}

public enum Prefix {
MR("Mr"), MS("Ms"), MRS("Mrs"), MISS("Miss");
MR("Mr", "Sr"),
MS("Ms", "Ms"), // intentionally the same
MRS("Mrs", "Srta"),
MISS("Miss", "Sra");

private final String title;
private final String enTitle;
private final String esTitle;

Prefix(String title) {
this.title = title;
Prefix(String enTitle, String esTitle) {
this.enTitle = enTitle;
this.esTitle = esTitle;
}

@Override
@NonNull
public String toString() {
return title;
if ("es".equals(Locale.getDefault().getLanguage())) {
return esTitle;
} else {
// default to english
return enTitle;
}
}

@NonNull
public static Prefix fromString(String title) {
for (Prefix value : Prefix.values()) {
if (value.title.equals(title)) {
if (value.enTitle.equals(title) ||
value.esTitle.equals(title)) {
return value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.rockthevote.grommet.util.Dates;

import java.util.Date;
import java.util.Locale;

import rx.functions.Func1;

Expand Down Expand Up @@ -286,29 +287,37 @@ public ContentValues build() {
}

public enum Race {
OTHER("Other"),
AM_IND_AK_NATIVE("American Indian / Alaskan Native"),
ASIAN_PACIFIC_ISLANDER("Asian / Pacific Islander"),
BLACK("Black (not Hispanic)"),
HISPANIC("Hispanic"),
MULTI_RACIAL("Multi-Racial"),
WHITE("White (Not Hispanic)"),
DECLINE("Decline to state");
OTHER("Other", "OTRO"),
AM_IND_AK_NATIVE("American Indian / Alaskan Native", "Nativoamericano"),
ASIAN_PACIFIC_ISLANDER("Asian / Pacific Islander", "Asiatico"),
BLACK("Black (not Hispanic)", "Afroamericano"),
HISPANIC("Hispanic", "Hispano"),
MULTI_RACIAL("Multi-Racial", "Multi"),
WHITE("White (Not Hispanic)", "Anglosajón"),
DECLINE("Decline to state", "Rechazar");

private final String race;
private final String enRace;
private final String esRace;

Race(String race) {
this.race = race;
Race(String enRace, String esRace) {
this.enRace = enRace;
this.esRace = esRace;
}

@Override
public String toString() {
return race;
if ("es".equals(Locale.getDefault().getLanguage())) {
return esRace;
} else {
// default to english
return enRace;
}
}

public static Race fromString(String race) {
for (Race val : values()) {
if (val.toString().equals(race)) {
if (val.enRace.equals(race) ||
val.esRace.equals(race)) {
return val;
}
}
Expand All @@ -317,25 +326,33 @@ public static Race fromString(String race) {
}

public enum Party {
DEMOCRATIC("Democratic"),
REPUBLICAN("Republican"),
NO_PARTY("none"),
OTHER_PARTY("Other");
DEMOCRATIC("Democratic", "Demócrata"),
REPUBLICAN("Republican", "Republicano"),
NO_PARTY("None", "Ninguno"),
OTHER_PARTY("Other", "Otro");

private final String party;
private final String enParty;
private final String esParty;

Party(String party) {
this.party = party;
Party(String enParty, String esParty) {
this.enParty = enParty;
this.esParty = esParty;
}

@Override
public String toString() {
return party;
if ("es".equals(Locale.getDefault().getLanguage())) {
return esParty;
} else {
// default to english
return enParty;
}
}

public static Party fromString(String party) {
for (Party val : values()) {
if (val.toString().equals(party)) {
if (val.enParty.equals(party) ||
val.esParty.equals(party)) {
return val;
}
}
Expand Down Expand Up @@ -373,23 +390,33 @@ public static Status fromString(String status) {
}

public enum PhoneType {
MOBILE("Mobile"), HOME("Home"), WORK("Work");
MOBILE("Mobile", "Móvil"),
HOME("Home", "Casa"),
WORK("Work", "Trabajo");

private final String phoneType;
private final String enPhoneType;
private final String esPhoneType;

PhoneType(String phoneType) {
this.phoneType = phoneType;
PhoneType(String enPhoneType, String esPhoneType) {
this.enPhoneType = enPhoneType;
this.esPhoneType = esPhoneType;
}

@Override
public @NonNull String toString() {
return phoneType;
if ("es".equals(Locale.getDefault().getLanguage())) {
return esPhoneType;
} else {
// default to english
return enPhoneType;
}
}

@NonNull
public static PhoneType fromString(String phoneType) {
for (PhoneType value : PhoneType.values()) {
if (value.phoneType.equals(phoneType)) {
if (value.enPhoneType.equals(phoneType) ||
value.esPhoneType.equals(phoneType)) {
return value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import com.rockthevote.grommet.ui.ViewContainer;
import com.rockthevote.grommet.ui.misc.StepperTabLayout;
import com.rockthevote.grommet.util.KeyboardUtil;
import com.rockthevote.grommet.util.LocaleUtils;
import com.squareup.sqlbrite.BriteDatabase;

import java.util.Locale;

import javax.inject.Inject;

import butterknife.BindView;
Expand Down Expand Up @@ -52,6 +55,10 @@ public class RegistrationActivity extends BaseActivity {

private KeyboardUtil keyboardUtil;

public RegistrationActivity() {
LocaleUtils.updateConfig(this);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -115,6 +122,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_cancel:
showCancelDialog();
return true;
case R.id.action_english:
LocaleUtils.setLocale(new Locale("en"));
recreate();
return true;
case R.id.action_espanol:
LocaleUtils.setLocale(new Locale("es"));
recreate();
return true;
default:
return super.onOptionsItemSelected(item);
}
Expand All @@ -137,6 +152,7 @@ private void showCancelDialog() {
RockyRequest._ID + " = ? ",
String.valueOf(rockyRequestRowId.get()));

LocaleUtils.setLocale(new Locale("en"));
finish();

}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import com.rockthevote.grommet.data.prefs.EventRegTotal;
import com.rockthevote.grommet.util.Dates;
import com.rockthevote.grommet.util.Images;
import com.rockthevote.grommet.util.LocaleUtils;
import com.squareup.sqlbrite.BriteDatabase;

import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.Locale;

import javax.inject.Inject;

Expand Down Expand Up @@ -252,6 +254,8 @@ public void onRegisterClick(View v) {
RegistrationCompleteDialogFragment dialog = new RegistrationCompleteDialogFragment();
dialog.setCancelable(false);
dialog.show(getFragmentManager(), "complete_dialog");

LocaleUtils.setLocale(new Locale("en"));
} else {
signaturePadError.setVisibility(View.VISIBLE);
}
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/com/rockthevote/grommet/util/LocaleUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.rockthevote.grommet.util;

import android.content.res.Configuration;
import android.os.Build;
import android.view.ContextThemeWrapper;

import java.util.Locale;

public class LocaleUtils {

private static Locale sLocale;

public static void setLocale(Locale locale) {
sLocale = locale;
if (sLocale != null) {
Locale.setDefault(sLocale);
}
}

public static void updateConfig(ContextThemeWrapper wrapper) {
if (sLocale != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Configuration configuration = new Configuration();
configuration.setLocale(sLocale);
wrapper.applyOverrideConfiguration(configuration);
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/menu/registration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
app:showAsAction="always">
<menu>
<item
android:id="@+id/english"
android:id="@+id/action_english"
android:title="English"
app:showAsAction="never"/>
<item
android:id="@+id/espanol"
android:id="@+id/action_espanol"
android:title="Espanol"
app:showAsAction="never"/>
</menu>
Expand Down
Loading

0 comments on commit fbde7ef

Please sign in to comment.