diff options
Diffstat (limited to 'main/src/cgeo/geocaching/utils/TranslationUtils.java')
-rw-r--r-- | main/src/cgeo/geocaching/utils/TranslationUtils.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/utils/TranslationUtils.java b/main/src/cgeo/geocaching/utils/TranslationUtils.java index e086ab6..a29c5a7 100644 --- a/main/src/cgeo/geocaching/utils/TranslationUtils.java +++ b/main/src/cgeo/geocaching/utils/TranslationUtils.java @@ -18,6 +18,7 @@ public final class TranslationUtils { private static final String translationFieldSeparator = "|"; public static final int translationTextLengthToWarn = 500; + private static final String TRANSLATION_APP = "com.google.android.apps.translate"; /** * Build a URI for Google Translate @@ -28,13 +29,18 @@ public final class TranslationUtils { * The text to be translated * @return URI ready to be parsed */ - public static String buildTranslationURI(final String toLang, final String text) { - return translationWebsite + translationForceClassicMode + translationAutoSelect + translationFieldSeparator + toLang + translationFieldSeparator + URLEncoder.encode(text).replace("+", "%20"); + private static String buildTranslationURI(final String toLang, final String text) { + String content = URLEncoder.encode(text); + // the app works better without the "+", the website works better with "+", therefore assume using the app if installed + if (ProcessUtils.isInstalled(TRANSLATION_APP)) { + content = content.replace("+", "%20"); + } + return translationWebsite + translationForceClassicMode + translationAutoSelect + translationFieldSeparator + toLang + translationFieldSeparator + content; } /** * Send Intent for Google Translate. Can be caught by Google Translate App or browser - * + * * @param toLang * The two-letter lowercase ISO language codes as defined by ISO 639-1 * @param text |