Windows exe的字符串本地化 [英] string localization for Windows exe

查看:53
本文介绍了Windows exe的字符串本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试在Windows应用程序(控制台应用程序)中实现字符串本地化。



为实现这一点,我已经完成了以下工作。



我在项目名称中添加了两个资源文件。 English.rc和Germany.rc



English.rc

我添加了一个字符串表。它的语言设置为英语(美国)



在Germany.rc

我添加了一个字符串表。它的语言设置为德国(德国)



在两个字符串表中我都添加了一个字符串资源条目



For English.rc



Hi,

I am trying to implement string localization in the windows application (Console app ).

To achieve this i have done following.

I have added two resource files in the project namele. English.rc and Germany.rc

In English.rc
I have added a string table. Its language is set to English(United States)

In Germany.rc
I have added a string table. Its language is set to Germany(Germany)

In both string tables i have adde a string resource entry

For English.rc

ID = IDS_STRING_Title
Value = 101 
Caption = EnglishCaption





适用于German.rc





For German.rc

ID = IDS_STRING_Title
Value = 101 
Caption = GermanCaption







我将两个rc文件中字符串资源的值保持为101.





我试图将此字符串用于代码中,如下所示。






I have kept the value of the string resources in both rc files to 101.


I am trying to consume this string into the code as follows.

#include "stdafx.h"
#include "windows.h"
#include "atlstr.h"
#include "resource1.h"
#include "resource.h"

int _tmain(int argc, _TCHAR* argv[])
{
	CString str( MAKEINTRESOURCE( IDS_STRING_Title ) ) ;
	
	
	return 0;
}









当我调试上述应用程序时, str总是加载EnglishCaption文本。 \

当我更改区域设置以将系统区域设置更改为德语(德语)或更改系统的显示语言时,它始终仅显示EnglishCaption文本。



为什么会这样。当我将系统区域设置设置为德语(德国)时,为什么应用程序不会使用德语(德语)语言从字符串表中获取字符串。 ???



我错过了什么?





When i debug above application, str gets always loaded with the "EnglishCaption" text. \
When i change the regional settings to change the system locale to German(German) or change Display language of the system, it always shows "EnglishCaption" text only.

Why this happens. Why application does not pick up the string from the string table with German(Germany) language when i set the system locale to German(Germany). ???

Am I missing something ??

推荐答案

这不行。



我们多年来一直使用这个解决方案



1.主要语言是在原来的exe-modul中

2.额外的语言资源编译成一个dll

3. rc-dll将被处理



本文介绍了这种方式:对扩展DLL的MFC应用程序的多语言支持 [ ^ ]



Sledgehammer方法:使用一些项目设置和#define,因此在exe中只包含一种语言。你将拥有每种语言的exe。 ;-)



如果你真的想挖掘i18n的深度,你可以从这里开始:http://msdn.microsoft.com/en-us/library/windows/desktop/dd318661(v=vs.85 ).aspx [ ^ ]
This wont work.

We using over years this solution

1. the primary language is in the original exe-modul
2. additional language resources are compiled in a dll
3. the rc-dll will handled

this article shows the way: Multiple language support for MFC applications with extension DLL[^]

Sledgehammer method: work with some projects settings and #define and so include only one language in a exe. Than you will have a exe for every language. ;-)

If you really will dig in the depths of "i18n" you can start here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318661(v=vs.85).aspx[^]


您可以执行卫星dll操作,也可以在一个rc文件中使用多个字符串表并切换。



在您的应用程序启动时调用此函数(m_iLang将是LANG_GERMAN,LANG_ENGLISH或其他)



You can do the "satellite dll" thing or you can also have multiple string tables in one rc file and switch.

Call this function in your application startup (m_iLang would be LANG_GERMAN, LANG_ENGLISH, or whatever)

::SetThreadLocale(MAKELCID(MAKELANGID(m_iLangID, SUBLANG_DEFAULT), SORT_DEFAULT));





然后拨打所有电话



then all your calls to

CString::LoadString()

将加载正确的语言


这篇关于Windows exe的字符串本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆