不可以将一个”空|空值”赋给产品字段,而不必继承默认语言的值吗?

huangapple go评论90阅读模式
英文:

Is not it possible to have an "empty|null" value assigned to a product field without necessarily inherit the value of the default language?

问题

我在翻译方面遇到了一个挑战。

基本上有几种语言设置(en-GB,it-IT,pt-PT),但默认语言始终是德语(de-DE)。

en-GB: "This is a sample text."
de-DE: "Dies ist ein Beispieltext."


我清理了英语(en-GB)的值,而德语(de-DE)的值显示出来。

en-GB: ""
de-DE: "Dies ist ein Beispieltext."


这是有道理的。这就是回退的作用。

然而,这里出现了问题。对于许多字段来说,将德语(de-DE)文本显示给前台客户并没有任何意义... 而客户确实希望这些字段为空,而不是德语。但当然,它继续显示德语文本... 即使在英语语言中该字段为空。

**问题:**难道不能将“空|空值”分配给产品字段,而不必继承默认语言的值吗?
英文:

I'm facing a challenge with translations.

Basically there are several languages setup (en-GB, it-IT, pt-PT), but the default language is always German (de-DE).

en-GB: "This is a sample text."
de-DE: "Dies ist ein Beispieltext."

I'm cleaning up the English (en-GB) value and the German (de-DE) value shows up.

en-GB: ""
de-DE: "Dies ist ein Beispieltext."

That makes sense. That's what fallback is all about.

HOWEVER, here comes the problem. For many-many-many fields it doesn't make any sense to display German (de-DE) texts for the storefront customers... and client really needs that to be empty, not German. But of course, it keeps displaying German texts... even tho the field is empty on the English language.

Question: Is not it possible to have a "empty|null" value assigned to a product field without necessarily inherit the value of the default language?

答案1

得分: 1

这将是在使用带有或不带有 translated 访问器的字段之间的区别。

假设您有一个产品描述,它已经用默认语言编写,但在次要语言中为空。后者是当前语言。

{{ page.product.translated.description }}

由于这里使用了翻译字段,它将是以当前语言编写的描述,如果存在的话。如果不存在,它将始终是默认语言的值作为后备。

但您也可以使用产品本身的 description 属性。

{{ page.product.description }}

这将始终输出当前语言的值,并且不会退回到默认语言的值。如果当前语言没有值,它将为 null

英文:

That would be the difference between using fields with or without the translated accessor.

Let's say you have a product description that has been written in the default language but is empty in the secondary language. The latter being the current language.

{{ page.product.translated.description }}

Since the translated field is used here, it will be the description written in the current language, if it exists. If it doesn't, then it will always be the value of the default language as a fallback.

You can however also use the description property of the product itself.

{{ page.product.description }}

This will always output the value for the current language and will not fallback to the default language's value. If there is no value for the current language it will be null.

huangapple
  • 本文由 发表于 2023年4月20日 04:20:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76058518.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定