googleads-consent-sdk-android icon indicating copy to clipboard operation
googleads-consent-sdk-android copied to clipboard

Text Localization

Open Sean343 opened this issue 6 years ago • 10 comments

Hi,

Is it possible to localise the text so that it supports multiple languages? I have a number of users from non-english speaking countries.

Sean343 avatar May 22 '18 23:05 Sean343

Hello, any update on it? I think this is one of the most important case in this project right now - if it is intendend to inform all EU users appropriately they should be given explenation in their language.

michalmachniak avatar May 23 '18 21:05 michalmachniak

Edit the lib yourself, create html for each language see this line https://github.com/googleads/googleads-consent-sdk-android/blob/master/consent-library/src/main/java/com/google/ads/consent/ConsentForm.java#L271 I think this lib is not build for localization from the start. They use html, js technology for both Android and iOS

dzungpv avatar May 25 '18 02:05 dzungpv

I think that native library/sdk should display also native dialog and not render html (with javascript and so one) instead.

iordachiv avatar May 25 '18 12:05 iordachiv

Idea for a quick solution: Probably it would be useful to exclude the path passed to webView.loadUrl() into a member variable which can be changed by setConsentFormUrl() or something like this to get multilanguage support without hacking the lib itself (I hate that! It breaks the ability to update). Then we can have multiple variants of consentform.html in the asset folder.

Diranus avatar May 25 '18 15:05 Diranus

I think a simple edit can support other language:

String countryiso3 = Resources.getSystem().getConfiguration().locale.getISO3Country();
this.webView.loadUrl("file:///android_asset/consentform_"+"countryiso3"+".html");

And then translate the html form for each language, put it in your asset folder and you are done

dzungpv avatar Jun 12 '18 12:06 dzungpv

Here are 10 languages for which I have ordered a translation. The texts were translated by a translation team. I cannot guarantee the correctness of the translation.

consentform.zip

Chinese (Simplified) Dutch French (France) German Italian Japanese Korean Russian Portuguese (Portugal) Spanish (Spain)

In the file ConsentForm.java I changed the function load(). In the strings file I added a "consentform" string with the filename for for every language I use.

    public void load() {
        if (this.loadState == LoadState.LOADING) {
            listener.onConsentFormError("Cannot simultaneously load multiple consent forms.");
            return;
        }

        if (this.loadState == LoadState.LOADED) {
            listener.onConsentFormLoaded();
            return;
        }

        this.loadState = LoadState.LOADING;

        // Codenia code
        **this.webView.loadUrl("file:///android_asset/" + Helper.getLocalizedString(R.string.consentform) + ".html");**
        //this.webView.loadUrl("file:///android_asset/consentform.html");
    }

codenia avatar Jun 12 '18 12:06 codenia

Thank you for sharing. I think that Chinese, Japanese, Korean and Russian should not be provided with library. As far as I know only for EEA (European Economic Area) countries this consent should be displayed. European Economic Area countries: https://europa.eu/european-union/about-eu/countries_en#tab-0-0

witoldgoralski avatar Jun 13 '18 11:06 witoldgoralski

Yes, but in Europe there are many Chinese people who have set Chinese language on their smartphone or many Russians who have set Russian language. (And so on)

codenia avatar Jun 13 '18 12:06 codenia

It make sense for me. But it is bad news.

witoldgoralski avatar Jun 13 '18 14:06 witoldgoralski

I am using #86 as temporary solution with my own consentform.html files and it's working well.

vrerabek avatar Nov 12 '18 10:11 vrerabek