对于 I18N,在代码中存储与表单无关的字符串的位置!
我们有一个相对较大的 dotNet 应用程序,并且想知道在代码中存储与表单无关的字符串的最佳位置在哪里?我们不希望在应用程序的解决方案资源管理器窗口中显示数十个未折叠的 resx 文件。任何建议将不胜感激。
We have a relatively large dotNet application and are wondering where is the best place to store strings in our code that aren't related to forms? We don't want to have tens of un-collapse resx file being displayed in our application's solution explorer window. Any advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Android 有一种有趣的方法来做到这一点 - 基本上有一个默认目录,然后为每个其他区域设置一个单独的目录。它看起来非常干净并且可以折叠,因为它们每个都有自己的文件夹。
看一下这里,看看是否值得在之后对代码进行建模:
http://developer .android.com/guide/topics/resources/localization.html
Android has an interesting way of doing it - basically having a default directory, then a separate one for each other locale. It looks pretty clean and would be collapsible since they each have their own folders.
Take a look here and see if it's worth modeling your code after:
http://developer.android.com/guide/topics/resources/localization.html
我们在输出之前将所有字符串包裹在 i18n() 周围。大多数字符串都在代码中。 i18n 函数将获取字符串和上下文,并在 PO 文件中查找它并返回 i18n 结果,我假设您已经知道这一点。
PERL 示例
We wrap all strings around i18n() right before output. Most strings are in the code. The i18n function will take the string and context and look it up in a PO file and return the i18n'd result, which I assume you already know that.
A PERL Example
通常人们倾向于为 resx 文件创建简单的源目录。
人们可以创建 LocalizedResources 文件夹并将所有可翻译的 resx 文件放在那里,以及不可翻译的 resx 文件的 NonLocalizedResources (如果您使用它们;在足够大的项目中,您这样做的可能性很高)。
Typically people tend to create simple source directories for resx files.
One can create LocalizableResources folder and place all translatable resx files there, as well as NonLocalizableResources for non-translatable resx files (if you use them; in sufficiently large project chances are high that you do).