Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am trying to start with internationalisation using gettext string extractor.

I have created sample code as follows. But it failed to build.

C++
#include "SupportLanguage.hpp"
#include <iostream>
#include <locale.h>
#define _(STRING) gettext(STRING)

#include "libintl.h"
using namespace std;
class SupportLanguage {

public:    
    int x = 0;    
    void display();
};

void SupportLanguage :: display(){
    cout << " Hello World" << endl;    
    cout<< "Welcome" <<endl;    
    cout << gettext("How are you doing ?") <<endl;
}

int main(){
 
    SupportLanguage sl ;    
    sl.display();
    return 0;
}

Error Message:

Ld DerivedData/Internationalise/Build/Products/Debug/Internationalise.app/Contents/MacOS/Internationalise normal x86_64
cd /Users/UserName/WorkPlace/Internationalise
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug -F/Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug -filelist /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Intermediates/Internationalise.build/Debug/Internationalise.build/Objects-normal/x86_64/Internationalise.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../Frameworks -mmacosx-version-min=10.11 -Xlinker -no_deduplicate -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Intermediates/Internationalise.build/Debug/Internationalise.build/Objects-normal/x86_64/Internationalise_dependency_info.dat -o /Users/UserName/WorkPlace/Internationalise/DerivedData/Internationalise/Build/Products/Debug/Internationalise.app/Contents/MacOS/Internationalise

Undefined symbols for architecture x86_64:
"_libintl_gettext", referenced from:
gettext(char const*) in SupportLanguage.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

OS: OS X

What is the problem here?

Thanks

What I have tried:

I hardly understand the problem.
Posted
Updated 25-Jul-16 5:47am
v2

You cant use gettext in that manner. Construct some string object and use it as input param.
 
Share this answer
 
Comments
Member 4530872 25-Jul-16 11:12am    
Thanks for the reply, I tried creating a string object as follows

string str = “Create Object";

string tempStr(str);

changed the print statement as

cout << gettext(tempStr) <<endl;

but Xcode(Mac IDE) says “ No matching function for gettext”

it seems as syntax error.
The problem is solved now after including “gettext.h”.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900