firebase / firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
https://firebase.google.com/
Apache License 2.0
4.57k stars 1.05k forks source link

Localize FirebaseUI to other languages #9

Closed thiagoantunes closed 7 years ago

thiagoantunes commented 8 years ago

Is there any support for other languages?

bojeil-google commented 8 years ago

Not currently, but that's the long term goal. The code will most likely be open sourced ahead of that and you'll have the ability to modify the templates with your target language.

BrunoGiubilei commented 8 years ago

bojeil-google, i have the same question. Can i change this file ? Or get a pretify model ?

"https: //www.gstatic.com/firebasejs/ui/live/0.5/firebase-ui-auth.js"

alfongj commented 8 years ago

@BrunoGiubilei

Technically you can modify that file, but I would recommend waiting for us to open source it (we are working on it and hope to be ready soon) and modify the open sourced version. Currently our implementation uses some internal google dependencies that could make it a bit too complicated for you to modify it yourself.

By the way, could you please comment on what is your use case? Is it supporting different locales? If so, could you comment which?

BrunoGiubilei commented 8 years ago

i need suport for portuguese, by the way, i hope you can use lan atribute for meta tag to get how language user use

alfongj commented 8 years ago

Thanks for the feedback! We will take that into consideration.

jalajc commented 8 years ago

@alfongj would love to see a Hindi language version. Getting meta tag to know language is the noble way as @BrunoGiubilei suggested. Would rather prefer a config parameter so that dynamic language interchange is possible with users choice. Interestingly, majority of internet population is multilingual. So, I think boil-the-ocean logic could be: if { Firebase lang config parameter present; use that}; elseif {html hreflang present, pick that}; else {default to browser/system lang/eng}

BrunoGiubilei commented 7 years ago

@alfongj i create this code to modify text to portuguese after elements inserted in DOM:

`var clock = setInterval(query, 1000), term = "Sign in with", portugueseTerm = "Entrar com o ", change = false;

var uiConfig = {

    'signInSuccessUrl': 'main.html',
    'signInOptions': [
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.TwitterAuthProvider.PROVIDER_ID,
        firebase.auth.GithubAuthProvider.PROVIDER_ID,
        firebase.auth.EmailAuthProvider.PROVIDER_ID
    ],
    'tosUrl': 'terms.html',
};

if (typeof localStorage["firebaseui::rememberedAccounts"] == "undefined") {

    var ui = new firebaseui.auth.AuthUI(firebase.auth());
    ui.start('#firebaseui-auth-container', uiConfig);
} else {

    window.location.href = "main.html";
}

function query() {

    if (change == true) {

        clearInterval(clock);
    }

    for (i in document.getElementsByTagName('span')) {

        if (typeof document.getElementsByTagName('span')[i].textContent != "undefined") {

            var element = document.getElementsByTagName('span')[i];

            element.textContent = element.textContent.replace(term,portugueseTerm);
            change = true;
        }
    }
}`

it´s not sexy, but works!

alfongj commented 7 years ago

@BrunoGiubilei

Thanks for sharing! I am glad you were able to make it work.

We hope to make it easier in the future though, so less work is required on your side :)

gpechim commented 7 years ago

@alfongj this solution solve your question and other places that you want translate depending on the browser language, it works too!

In fact this is also a function for the translation of languages regardless of which project it is. Enjoy \o/`

var initTranslate = function() {
    setTimeout(function() {
    dl = 'pt-BR';
    bl = navigator.language;
    google = 'Google';
    facebook = 'Facebook';
    email = 'password';
    bl === 'en-US' || bl === 'en-us' ? runlang(bl) : runlang(dl);

    function translate(text, provider) {
        var container = $('.firebaseui-idp-' + provider.toLowerCase() + ' .firebaseui-idp-text-long');
        if(provider === 'password'){
            provider = 'email';
            container.text(text+' '+provider);
        } else{
            container.text(text+' '+provider);
        }
    }

    function runlang(lang) {
        if (lang === 'en-US' || lang === 'en-us') {
            sign_in = 'Sign in with';
            translate( sign_in, google );
            translate( sign_in, facebook );
            translate( sign_in, email );
        } else {
            sign_in = 'Entrar com';
            translate( sign_in, google );
            translate( sign_in, facebook );
            translate( sign_in, email );
        }
    }
}, 1500); }; window.addEventListener('load', initTranslate);`
jalajc commented 7 years ago

@gpechim This is great. Though this has valid use cases, thing that concerns me here is we are first having a text which is loaded, and then pulling the the translated text resulting in some extra data exchange and round trips. But ya in absence of alternative this seems ok. @ all I would prefer loading a fairly pre transalated flavor of firebase-ui js , may be specified through some language config parameter. But, I believe, this also has to be taken at firebase.js level as many parameters /error messages originate there.

drishi94 commented 7 years ago

Thank you very much @gpechim. We have plans to work on adding language support to FirebaseUI gradually, but for the time being I hope some of the workarounds posted on this thread are helpful.

MentalGear commented 7 years ago

Still no international support for login from the Firebase team ... ? Common guys, if you want firebase to be used globally, you should put the effort into it, especially since you're now google & money shouldn't be an issue.

kosenin commented 7 years ago

Guys, could you please opensource the library or enable support of Russian language? Would be great! Thank you.

TMSCH commented 7 years ago

Hi @kosenin, FirebaseUI is already open sourced.

mikaturk commented 7 years ago

Any news on this? or is modifying text after the dom loads still the best thing to do?

phyr0s commented 7 years ago

Any news?¿?

channing-google commented 7 years ago

This is fixed in FirebaseUI 2.2.1.

See https://github.com/firebase/firebaseui-web#localized-widget for instructions.

mikaturk commented 7 years ago

Thanks so much guys!

cpmech commented 6 years ago

Unfortunately, the solution in https://github.com/firebase/firebaseui-web#localized-widget does not allow for dynamically selecting the language. In fact, with more than 3 languages it becomes very tedious...

eduard2014 commented 5 years ago

Could you add LANGUAGE_CODE to uiConfig?

landsman commented 3 years ago

@channing-google this should be re-open. It's more hack than a proper solution. Building whole thing because localization is overkill (200kb each language).

crdev commented 2 years ago

How does this solution play with Angular? I don't think it does...

molavec commented 6 months ago

Is there a solution in 2024 to avoid the need for building code?