从资源文件链接到资源
我有一个全局资源文件:ContactDetails.resx。这里是网站上使用的地址和联系信息。
我还有一个联系页面,列出了所有联系方式,但根据语言而变化。因此,在英国网站上,英国联系方式将显示在顶部,而在法国网站上,法国详细信息将显示在顶部。
有没有办法嵌套资源,从不同资源的值中引用资源值?
I have a global resource file: ContactDetails.resx. In here are addresses and contact information used around the website.
I also have a contact page listing all the contact details, but changing depending on language. So on the UK website, the UK contact details appear at the top, whereas on the French website the French details will appear at the top.
Is there a way to nest resources, referencing a resource value from within the value of a different resource?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果某个资源值在您的法语资源文件中不存在,但在您的默认资源文件中存在,则系统将自动从默认资源文件中获取该值。
因此,如果您的本地化设置为
fr
,并且您的呼叫类似于:并且
ContactDetails.fr.resx
中不存在电话,那么它将从以下位置获取电话值:ContactDetails.resx
如果所有值都显示在页面上,但根据本地化以不同的顺序显示,我建议不要将这些值存储在资源文件中。资源文件变体是为了更改语言,而不是更改数据布局。
相反,我建议将它们存储在数据库中,并在页面上有 3 个文字控件,例如:
然后根据本地化,指定应为每个控件分配哪些值。
If a resource value doesn't exist in your French resource file, but does in your Default resource file, the system will automatically get the value from the default resource file.
So if your localization is set to
fr
, and your call is something like:And Telephone doesn't exist in
ContactDetails.fr.resx
then it will get the Telephone value fromContactDetails.resx
If all the values are to be displayed on the page, but in a different order depending on the localization I would recommend not storing these in a resource file. The resource file variations are for changes in language, not to change layout of data.
Instead I would recommend to store these in the database, and have 3 literal controls on the page like:
Then depending on the localization, specify which values should be assigned to each control.