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

Localization not work in the customization widget template #17269

Open
gaojianzhuang opened this issue Dec 21, 2024 · 8 comments
Open

Localization not work in the customization widget template #17269

gaojianzhuang opened this issue Dec 21, 2024 · 8 comments

Comments

@gaojianzhuang
Copy link

gaojianzhuang commented Dec 21, 2024

Describe the bug

I have enabled all the culture, localization-related features, and search forms. When I used the built-in search form widget in the layout, the localization worked well when I switched to a different language. But if I created a customization widget template in the backend. The localization would not work anymore when I changed the language.
image

Orchard Core version

orchardcore 2.1.0

image

To Reproduce

  1. Go to 'https://localhost:5001/Admin/'
  2. Click on 'https://localhost:5001/Admin/Templates'
  3. Add the "Widget__SearchForm" template.
  4. Go to the front-end page.
  5. Switch to a different language, the search form always displays the English version. But if I delete the "Widget__SearchForm" template, the issue will be resolved.
    image

Expected behavior

The localization should work well if I use the widget template created in the backend.
zh-CN:
image
en-US:
image

It seems like the "{{ "Enter your search term(s)" | t }}" code does not work in the template data.

Logs and screenshots

zh-CN:
image
en-US
image

@Piedone
Copy link
Member

Piedone commented Dec 21, 2024

I guess the PO identifiers don't match for the admin template. @hishamco perhaps you can chime in?

@hishamco
Copy link
Member

If those are custom localization resources you need to define them in PO files, try to add zh-CN.po in the Localization folder add the entires then have a try

@gaojianzhuang
Copy link
Author

gaojianzhuang commented Dec 25, 2024

If those are custom localization resources you need to define them in PO files, try to add zh-CN.po in the Localization folder add the entires then have a try

The "zh-CN.po" file already exists in the "Localization" folder and the translation key exists in the po file. It just doesn't work in the customization template data which was created in the backend template, but it works fine in the template file.
image

If I remove the template data in the admin backend, the "searchForm" will render the "SearchForm.liquid" template file in the dll file and it will work well.

It seems like the "{{ "Enter your search term(s)" | t }}" code not work in the template data context.

@hishamco
Copy link
Member

I will try to follow the reproduced steps and check

@hishamco
Copy link
Member

@gaojianzhuang how do you inject or display the search widget in your layout, unfortunately, I didn't use the built-in search form before, but I could figure out the localization issue once the search box shows up

@sebastienros
Copy link
Member

I believe the issue is a mismatch between the "context" value of the localization string and the one we use for an admin template. For file-system templates we use the filename, and it's set in each PO localization string. For an admin template I assume we could use the name of the template, but I am not even sure we set anything. So it's possible this has never worked.

@sebastienros sebastienros added this to the 3.x milestone Jan 2, 2025
Copy link
Contributor

github-actions bot commented Jan 2, 2025

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

@hishamco
Copy link
Member

hishamco commented Jan 3, 2025

I believe the issue is a mismatch between the "context" value of the localization string and the one we use for an admin template.

I expect that too, @gaojianzhuang could you please reply to my last comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants