-
-
Notifications
You must be signed in to change notification settings - Fork 70
Added custom multi language support #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How can I change the language? I can't get it to work. I didn't find the instructions in the 'readme'. Would you help me? |
@francinha02 In the forked version you can do it using the So, for example, if you want to set the language to be this.firebaseUiService
.setFirebaseUILanguage("pt_br")
.then(() => {
console.log("Changed language");
})
.catch((err) => {
console.log(err);
}); ℹ A default language can be provided with the |
Hi @francinha02, I installed your branch to use the language support. but it show error "Cannot find module 'firebaseui-angular'". UPDATE: I clone the code of your banch and run |
Hi everyone, Great job @l0ll098. One question to Creators, when will it be merged to master? |
Is this going to be merge any time soon. Or do we need to help resolving the conflict? |
First of all thanks to @l0ll098 for the PR. The PR is quite a big change, and I have to fully test this, before releasing it. Currently, I'm a bit short in time, but this should change in the next few weeks. The thing that I have to check is also, that the plugin doesn't get bloated by additional features as well as, that it keeps being easy to maintain (especially regarding the original firebaseui library - this still is just a wrapper) |
@l0ll098 Please try to resolve the conflicts, in order for me to check it. |
@RaphaelJenni thanks for your reply. |
@RaphaelJenni Resolved, now you should be able to test it and eventually merge it |
Strangely, there is still a conflict somewhere... I'll review your PR anyway. Just make sure, that it is mergeable. |
* Loads a series of previously registered Script(s) | ||
* @param resNames The list of resources to load | ||
*/ | ||
load(...resNames: string[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a return type
*/ | ||
load(...resNames: string[]) { | ||
let promises: any[] = []; | ||
promises = resNames.map((name) => this.loadResource(name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be written as a shorthand form. No need for initializing the array first. Additionally, the array should be correctly typed - not with any
.
* Loads a script given it's name. | ||
* @param name Name of the script to laod. | ||
*/ | ||
loadResource(name: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add return type
* Registers and then loads a list of Resource(s) | ||
* @param resource The list of resources | ||
*/ | ||
registerAndLoad(...resource: Resource[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add return type
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string | FirebaseAppConfig | null | undefined, | ||
zone: NgZone) { | ||
private static readonly COMPUTED_CALLBACKS = "COMPUTED_CALLBACKS"; | ||
private static readonly FIREBASEUI_CDN_VERSION = "4.5.0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version can't be hardcoded.
- I would need to update this string on every release.
- The firebaseui library is as such independent from this wrapper plugin, and as such everyone who uses this wrapper could use a different verison.
zone: NgZone) { | ||
private static readonly COMPUTED_CALLBACKS = "COMPUTED_CALLBACKS"; | ||
private static readonly FIREBASEUI_CDN_VERSION = "4.5.0"; | ||
private static readonly FIREBASEUI_CDN_URL = `https://www.gstatic.com/firebasejs/ui/${FirebaseuiAngularLibraryService.FIREBASEUI_CDN_VERSION}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to set a different URL. If someone wants to store it locally, this has to be adjusted.
return await new Promise((resolve) => { | ||
|
||
// Each "pollingMs" this method will check if the firebaseUiInstance has been defined | ||
const interval = setInterval(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this approach. Polling isn't the way to go.
@l0ll098 I really like your approach to the whole language thing, but there are a few problems with it. Angular as such, doesn't support realtime language switching. There is a third-party library for that, but it is not included in the core. From this perspective, adding something with this functionality is just not the way to go for an angular app. Secondly, for everyone using this library, not willing to change the language, has a package that is much bigger and does much more in the background as intended - after all this is just a lightweight wrapper. We now have two options:
|
Hi everyone, I know it's been a while but here I am. Since new versions of the original project were pubblished, I've updated the fork to the latest version available. I've also improved those things pointed out by @RaphaelJenni in his review of this pr. And I have to admit it, they were good points 😎 The forked version with i18n support is available on npm with the name @RaphaelJenni could you please link it somewhere in your readme file? |
@l0ll098 Cool! Nice to have my first real fork 😄 I'm gonna add a reference on the README page. Thanks for your work! |
Hi,
Since the version of the FirebaseUI-Web library published on npm doesn't yet support i18n (firebase/firebaseui-web#242), I've wrote a small piece of code that can dynamically change the language of the FirebaseUI widget.
It does this by deleting the old one, loading the correctly localized build of FirebaseUI from the Firebase CDNs and starting it again. A default language can be specified in the
firebaseUiAuthConfig
object in thesrc/app/app.module.ts
file, even though this is not required. In case the language has not been set or if it's set to "en", it will use the FirebaseUI version shipped with NPM.This approach adds also support for RtL (Right to Left) languages.
I've also edited the main page of the test app, to demonstrate this in action.
@RaphaelJenni Let me know what you think
Fixes #115 #102 #42 #39
Addresses also: #119