Skip to content

Commit

Permalink
Multiple Language Support
Browse files Browse the repository at this point in the history
This is similar to https://gerrit.omnirom.org/#/c/14014

A lot of the features built in the older patch set have been split
out into separate patches, most of which have already been merged.
The remaining functionality here should all be directly related to
language selection and loading. We always load English as a base
before loading other languages over the top of the base. The idea
is that if another language is missing a translation, then we will
still display the English.

Maybe still to do: read the /cache/recovery/last_locale file and
load a language based on that. For me, this file contains just:
en_US
We probably won't bother with region specific translations so we
would have to look at either trimming off the _US or using some
other method like perhaps a symlink or a combination of the two.

Thanks to _that for twmsg.cpp class

Change-Id: I9647a22e47883a3ddd2de1da51f64aab7c328f74
  • Loading branch information
Dees-Troy committed Dec 19, 2015
1 parent 28f0a92 commit 74db157
Show file tree
Hide file tree
Showing 40 changed files with 4,041 additions and 2,086 deletions.
5 changes: 5 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
LOCAL_CFLAGS += -DTW_USE_NEW_MINADBD
endif
ifneq ($(TW_DEFAULT_LANGUAGE),)
LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=$(TW_DEFAULT_LANGUAGE)
else
LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=en
endif

LOCAL_ADDITIONAL_DEPENDENCIES := \
dump_image \
Expand Down
15 changes: 10 additions & 5 deletions data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "find_file.hpp"
#include "set_metadata.h"
#include <cutils/properties.h>
#include "gui/gui.hpp"

#define DEVID_MAX 64
#define HWID_MAX 32
Expand Down Expand Up @@ -229,7 +230,7 @@ void DataManager::get_device_id(void) {
}

strcpy(device_id, "serialno");
LOGERR("=> device id not found, using '%s'\n", device_id);
LOGINFO("=> device id not found, using '%s'\n", device_id);
mConstValues.insert(make_pair("device_id", device_id));
return;
}
Expand Down Expand Up @@ -616,8 +617,10 @@ void DataManager::SetBackupFolder()
}
}
} else {
if (PartitionManager.Fstab_Processed() != 0)
LOGERR("Storage partition '%s' not found\n", str.c_str());
if (PartitionManager.Fstab_Processed() != 0) {
LOGINFO("Storage partition '%s' not found\n", str.c_str());
gui_err("unable_locate_storage=Unable to locate storage device.");
}
}
}

Expand Down Expand Up @@ -890,6 +893,8 @@ void DataManager::SetDefaultValues()
#endif
mValues.insert(make_pair("tw_mount_system_ro", make_pair("2", 1)));
mValues.insert(make_pair("tw_never_show_system_ro_page", make_pair("0", 1)));
mValues.insert(make_pair("tw_language", make_pair(EXPAND(TW_DEFAULT_LANGUAGE), 1)));
LOGINFO("LANG: %s\n", EXPAND(TW_DEFAULT_LANGUAGE));

pthread_mutex_unlock(&m_valuesLock);
}
Expand Down Expand Up @@ -1033,7 +1038,7 @@ void DataManager::Output_Version(void)
}
FILE *fp = fopen(Path.c_str(), "w");
if (fp == NULL) {
LOGERR("Unable to open '%s'.\n", Path.c_str());
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
return;
}
strcpy(version, TW_VERSION_STR);
Expand Down Expand Up @@ -1069,7 +1074,7 @@ void DataManager::ReadSettingsFile(void)
{
usleep(500000);
if (!PartitionManager.Mount_Settings_Storage(false))
LOGERR("Unable to mount %s when trying to read settings file.\n", settings_file);
gui_msg(Msg(msg::kError, "unable_to_mount=Unable to mount {1}")(settings_file));
}

mkdir(mkdir_path, 0777);
Expand Down
2 changes: 1 addition & 1 deletion find_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ string Find_File::Find_Internal(const string& filename, const string& starting_p

d = opendir(starting_path.c_str());
if (d == NULL) {
LOGERR("Find_File: Error opening '%s'\n", starting_path.c_str());
LOGINFO("Find_File: Error opening '%s'\n", starting_path.c_str());
return "";
}

Expand Down
4 changes: 3 additions & 1 deletion gui/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ LOCAL_SRC_FILES := \
mousecursor.cpp \
scrolllist.cpp \
patternpassword.cpp \
textbox.cpp
textbox.cpp \
twmsg.cpp

ifneq ($(TWRP_CUSTOM_KEYBOARD),)
LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
Expand Down Expand Up @@ -107,6 +108,7 @@ ifeq ($(TW_CUSTOM_THEME),)
ifeq ($(TWRP_NEW_THEME),true)
TWRP_THEME_LOC := $(commands_recovery_local_path)/gui/theme/$(TW_THEME)
TWRP_RES := $(commands_recovery_local_path)/gui/theme/common/fonts
TWRP_RES += $(commands_recovery_local_path)/gui/theme/common/languages
TWRP_RES += $(commands_recovery_local_path)/gui/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
# for future copying of used include xmls and fonts:
# UI_XML := $(TWRP_THEME_LOC)/ui.xml
Expand Down
Loading

0 comments on commit 74db157

Please sign in to comment.