-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Autoroute Pattern and {{ | t }} filter #5599
Comments
I did this ugly patch to fix the issue but we might want eventually to do this better. public LocalizedString this[string name]
{
get
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
var translation = GetTranslation(name, _context, CultureInfo.CurrentUICulture, null);
return new LocalizedString(name, translation ?? name, translation == null);
}
} |
This is weird, we could use Is it because you need to get the proper content translation? |
The translated string is not taken from the content. I'm using a global translated string in my autoroute pattern and I want it to be translated in the culture of the content item. So, here I'm using a LocalizationPart on a content item and I want that my autoroute be saved with some french or english patterns. Example : /{{ "category" | t | slugify }}/{{ "apple" | t | slugify }}/{{ contentitemId }} fr.po file : msgid "category" msgid "apple" |
In nutshell what you want did is "Slug/ Route Localization"? |
Yes AutoroutePart pattern localization. Right now we can't because it's always using the CultureInfo.CurrentUICulture when we parse a Liquid template. It should use the LocalizationPart.Culture to properly translate in the correct culture. |
Ya, could use |
If you want me to try this one, I can start a PR |
Go for it have fun 😄 |
|
You will need to call Render with a custom instance of |
I really forgot |
Same result. |
Ended up doing this for now which works :
|
@Skrypt seems you create a custom |
No in the latest bits I don't do anything else than the changes I made in my last post. I tried doing an instanciation of the LiquidTemplateContext like @sebastienros suggested but it doesn't take in consideration the LiquidTemplateContext.Culture at all. So it is using the CultureInfo.CurrentUICulture somewhere else down the line. I've found a place where we explicitly set it that way but not sure yet. |
Ok, I'm working on it ... |
We cannot use {{ "something" | t }} in an autoroute pattern because it will always use the CultureInfo.CurrentUICulture. I tried forcing a Culture on the LiquidTemplateContext and it doesn't take it into consideration.
The text was updated successfully, but these errors were encountered: