Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对于I18N,在代码中存储与表单无关的字符串的位置!_C#_String_Internationalization_Resx - Fatal编程技术网

C# 对于I18N,在代码中存储与表单无关的字符串的位置!

C# 对于I18N,在代码中存储与表单无关的字符串的位置!,c#,string,internationalization,resx,C#,String,Internationalization,Resx,我们有一个相对较大的dotNet应用程序,想知道在代码中存储与表单无关的字符串的最佳位置是哪里?我们不希望在应用程序的解决方案资源管理器窗口中显示数十个未折叠的resx文件。如有任何建议,将不胜感激 Android有一种很有趣的方法——基本上有一个默认目录,然后每个区域都有一个单独的目录。它看起来很干净,而且可以折叠,因为它们都有自己的文件夹 看看这里,看看是否值得在以下情况下对代码进行建模: 在输出之前,我们将所有字符串环绕i18n()。大多数字符串都在代码中。i18n函数将获取字符串和上下文

我们有一个相对较大的dotNet应用程序,想知道在代码中存储与表单无关的字符串的最佳位置是哪里?我们不希望在应用程序的解决方案资源管理器窗口中显示数十个未折叠的resx文件。如有任何建议,将不胜感激

Android有一种很有趣的方法——基本上有一个默认目录,然后每个区域都有一个单独的目录。它看起来很干净,而且可以折叠,因为它们都有自己的文件夹

看看这里,看看是否值得在以下情况下对代码进行建模:


在输出之前,我们将所有字符串环绕i18n()。大多数字符串都在代码中。i18n函数将获取字符串和上下文,并在PO文件中查找它,然后返回i18n的结果,我想您已经知道了

PERL示例

## we have this handy noop function for putting strings into a PO file
i18n_noop('Some string that needs to be i18n','This is the context'); 

## once our string has been captured in the PO file, we can assign it to a scalar variable
my $str = 'Some String that needs to be i18n';

## before printing the str we pass it i18n, this function will take the $str and find the appropriate translation.
print i18n($str);

## we could also do this.  The first argument is the string to be translated.  the second argument is the context.
i18n('Some string that needs to be i18n','This is the context'); 

通常人们倾向于为resx文件创建简单的源目录。

您可以创建LocalizableSources文件夹并将所有可翻译的resx文件以及不可翻译的resx文件的非LocalizableSources(如果您使用它们;在足够大的项目中,这样做的可能性很高)

“我们不希望在应用程序的“解决方案资源管理器”窗口中显示数十个未折叠的resx文件。”-…折叠它们?请详细说明。我对I18N比较陌生!