How to add a variety of languages ​​in the same project

zhaozj2021-02-16  47

This should be a small trick to use VC, but before I plan to do it, I found it online, I didn't find it (maybe I fill in the keyword is not right, "I have a reference to you here, I hope that everyone can provide convenience, don't need to be so hard.

意图: Implementing a variety of languages ​​in the same project, if the debug is successful, you can compile multiple language versions of the program.

Platform: Win2000 Pro SP4, VC 6.0, SDK

Under normal circumstances, writing programs will use the project production wizard, and the generated project has two compiling versions, one is debug, and the other is Release, my purpose is to add a variety of language compilation, while needing multiple languages ​​.rc Document (Source file), then have some simple settings, it is OKAY.

I have added a lot of pictures, so it is easier to understand, and it is also the pain of reading the text (the text of the big one with the computer is really painful).

Below we start:

1. First, based on the .rc file in the project file, make a variety of .rc files, which is to replace the relevant dialogs, attribute pages, and some ID texts to other languages, here you need to pay attention, Different language versions of .rc files, contain a lot of identical icons (ICON), dialogs (Dialog), String Table, select the corresponding language in the SourceView in the VC compiler. For example, if it is English, these are all selected to select English (u.s.).

2. Add a multi-language compilation version, select Build-> Configurations, click Add, add the corresponding language compiling version, I added here is ENGLISH RELEASE. Then add a variety of language versions.

Add multiple languages

3. Edit the Project Setting of different language versions. Click on Menu Project-> Settings to modify the corresponding settings

Setting Output Directories: Includes Intermediate and Output Files, I am set to ENGLISH RELEASE here.

Set Output File Name: I am setting it to English_release / KTREXE.EXE

Setting Language: English (USA)

4. Add Source Files

A dialog box will pop up, don't use it.

At this point you can see in the resourceView of your compiler:

If you need to modify different languages ​​in the future, you can modify the corresponding resources file.

5. Click Project-> Settings, click on the.rc file you click.

Check Exclude File from Build

Select "Yes", each .rc file separately select the corresponding language compiling version, such as win32 english release, select WinApp1_english.rc, then tick in Exclude File from Build.

6. Compile:

Select build-> Batch Build

Select the language you want to compile, select Selection Only, click Rebuild All.

7. At this point, you can see your .dsp file has been modified. I have asked this issue in the 9CBS forum, and there is a different solution, I will post them:

My operation is an engineering that is generated in VC 6.0, and this project code is added, debugged, and running is Okay.

Since the project is Simplified Chinese, I want to add other language versions, I will replace the Simplified Chinese project to other languages ​​(such as Spanish) on the basis of .rc replica, then I am in build-> configurations The spanish release is added, and the language environment, input path, etc. in Project-> Settings are set. Then I will add me in Project-> Add Files I just replaced the language .rc file added.

The purpose is to debug with Debug, then select the language type I want to compile in the build-> batch building option, compile multiple languages.

The problem is VC6.0 prompt "Multiple.rc Files Exist in this Project. Only One Can Be Marked As Included in The Build. The Others Will Be Excluded Frome The Build."

Excuse me, how to solve this problem, I have been looking for two days online, in other newsgroups on the form, I didn't find the answer. Is there anything wrong with me? Please give a prompt. Thank you!

Save your current .rc, then replace all Chinese in other languages, don't store it as other Other.rc.

GetResourceInstance () gets the resource handle. Change to another other.rc, (setResourceHandle)

You can get it.

Because all IDs have not changed, all programs can run normally.

It is best to make resources into DLL, switch to LoadResource

It is also a good way to write into II!

Answer in other forums:

Several solutions:.... 1 Place all your resources into one big rc file.2 Exclude the additional rc files from the build and include them by theresource includes (right mouse click on the resource file in the resourceeditor) In this case you have to take care that bitmaps and others are onlyincluded once! 3. Create seperate DLL's for each language and use the corresponding handleto this DLL when loading resources. Read the docu to AfxSetResourceHandlewhen you are using the MFC.

1) use the "resource includes" menu item in VC C 6.0 and include oneresource in the other (ie #include "file.rc") Make sure that there are noconflicts and each resource is properly marked with the correct language.Mark the RC FILE AS Excluded from The Build. It Will Get Built Anyway Sinceit Was Included In The Main Rc.2) Have Separate DLL (IE a Separate Sub-Project) for Each RC File (THESATELITE DLL Approach To Localization)

If you are unhappy with having separate builds for each language thenyou'll have to combine the .rc files with (or without if they does not usesame identifiers) the proper LANGUAGE ID # ifdef's. If you do not knowabout these, use the Resource Editor Built Into the Environment To createa new .rc with element variants in seved languages. The open the fileand analyse it.

In VS.NET 2003 click on Build> Configuration ManagerYou will find your project. Now it is possible to select New in the combo "Active Solution Configuration" you can add new settings to the current onesDebug / Release.In VS6 click on Build-> Configurations. you will find your project displayedas a tree. Click on Add to add new configurations.In both caes you will be asked what base configuratin should be copied.Now you can create different Release modes like German / English / Bavarian andso on .. .For each configuration you can define diffrent rc files to be excluded fromthe build. Also you can define different output directories.The disadvantage is that you always have a complete binary for a languageand you can not switch the language on user request!

If you have any questions, please contact me: danielxu22@cellink.com.cn

转载请注明原文地址:https://www.9cbs.com/read-23507.html

New Post(0)