Skip to content
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

[HELP WANTED] Add / Fix Localization #101

Open
iammukeshm opened this issue Jan 29, 2022 · 4 comments
Open

[HELP WANTED] Add / Fix Localization #101

iammukeshm opened this issue Jan 29, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@iammukeshm
Copy link
Member

iammukeshm commented Jan 29, 2022

It would be great if someone from the community can take up this task.

Basically, all you need to do is fix / add localization resources.

Most of the texts in the Blazor components are not localization-ready. You have to add something like

@inject IStringLocalizer<NavMenu> L

to the component where NavMenu is the component name.

Now, you can use @L["Text"] for implementing localization.

For Example

Convert

<MudNavLink Href="/dashboard" Match="NavLinkMatch.All" Icon="@Icons.Material.Outlined.Dashboard">Dashboard</MudNavLink>

into

<MudNavLink Href="/dashboard" Match="NavLinkMatch.All" Icon="@Icons.Material.Outlined.Dashboard">@L["Dashboard"]</MudNavLink>

Similarly, go through each and every component of the project and do the required changes. Even if you could do this change for a single component, I would appreciate it :)

Once that's done, Navigate to the Client project to Client/Resources

Here is where you can find the RESX files arranged in a folder view.

For example,

the NavMenu.razor component resides under Client/Shared/NavMenu.razor

and the RESX file for this component resides under Client/Resources/Shared/NavMenu.{lang}.resx where {lang} is the LanguageKey.

In this RESX file, add the Name and Values, where Name is what you mentioned under @l["Dashboard"] and Value will be the localizes string.

Also note that the existing RESX files are copied over from BlazorHero. Thus, there can be chances that RESX files are in different directories altogether for certain components. So, Re-arrangement of RESX might also be necessary to properly load Localization files.

Thanks for the support! I will leave a sample commit for your reference.

@iammukeshm iammukeshm added enhancement New feature or request help wanted Extra attention is needed labels Jan 29, 2022
@iammukeshm iammukeshm added this to the Release 1.0 milestone Jan 29, 2022
iammukeshm added a commit that referenced this issue Jan 29, 2022
@xlogex
Copy link
Contributor

xlogex commented Jan 29, 2022

image
it need move in right resource path ...
otherwise these resource cannot loaded
image

@iammukeshm
Copy link
Member Author

Yes, RESX re-arrangement is also needed.

@iammukeshm iammukeshm linked a pull request Jan 29, 2022 that will close this issue
@iammukeshm iammukeshm removed a link to a pull request Jan 29, 2022
@CanMehmetK
Copy link

CanMehmetK commented Jan 29, 2022

Changing all Label="..." with Label="@l["..."]"

       Label=\"([^@].*?)\"
       Label="@L["$1"]"

May be done with check
just an idea

iammukeshm added a commit that referenced this issue Jan 30, 2022
@kallievz
Copy link

kallievz commented Mar 6, 2022

Could the option to re-use the localization for the api module not be investigated? Don see the need to create regx on ui, and maintain on api? Single source of localization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants