I am new to Cocos2D-X, I'd like to know how to do "Internationalization" (Texts in English, Chinese, French, Japanese, etc) in Cocos2D-X.
I know how to do "Internationalization" in Android, IOS. Is there a way to do
internationalization in Cocos2D-X directly or should I do
internationalization for each platform (IOS, Android, Winphone, etc) I publish the App to ?
Could anyone help me ?
Thank you very much.
Best regards!
You can create an excel sheet file for all strings resources used in game in various languages as columns and one column for key. You columns will be like.
KEY | ENGLISH | HINDI | CHINESE
Now you can export a JSON file from this excel sheet and parse it and store in a key, value pair object on the basis of device language while loading or you can manually give option to change language in game.
You can get current language in cocos2dx using :
ccLanguageType currentLanguageType = CCApplication::sharedApplication()->getCurrentLanguage();
switch (currentLanguageType)
{
case kLanguageEnglish:
// load json file
break;
case kLanguageChinese:
break;
case kLanguageHindi:
break;
default:
break;
}
Related
Countries that use non-English characters use fonts that support their language. Chinese Windows users use Chinese fonts, and Korean users use Hangul fonts.
What I want to do is display an arbitrary directory, but I don't know what string will go into that directory. It may be in English, or it may be a path including Chinese or Japanese.
In the program I'm writing, I need to read the ttf file that matches this path and print the text.
I think the problem can be solved if I can know the fonts in use and the languages supported by the fonts in Windows Explorer installed on users' PCs.
Expressed in code, it would look like this.
FontInfo f = System.Control.Desktop.captionFont;
const char *ttfPath = f.ttfPath;
// ttfPath => C:\windows\Font\myFont.ttf
const char *language = f.design;
// ttfPath => "Korean" or "Thai"
I write down how I found it. If you have a better way, please share.
1-Retrieve the system font family name:
Button btncsharp = new Button();
btncsharp.Content = "SystemFonts";
btncsharp.Background = SystemColors.ControlDarkDarkBrush;
btncsharp.FontSize = SystemFonts.IconFontSize;
btncsharp.FontWeight = SystemFonts.MessageFontWeight;
btncsharp.FontFamily = SystemFonts.CaptionFontFamily;
cv1.Children.Add(btncsharp);
2-Retrieve TTF file name by font family name
Registry :
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
I'm trying to build a Prisoner's Dilemma game in Z-Tree (the toolkit for building game theory experiments), and have encountered two irritating problems.
I haven't succeeded in applying formatting to the output inside of an item. Specifically, I'd like to display the number of years of prison each player gets at the end of a game, in the format:
Years of Prison: value
using the Layout dialogue of the Item box. Not using the layout and inserting the values directly into the text leads to a far too messy display.
Is there a way to do that using variables (conceptually, something like Payoff = {\rtf \fs30 Payoff}), and not concrete values (like !text: 1 = {\rtf \fs30 1}).
Is there a way to enable UTF-8 encoding? I have some letters (like č or š) which aren't being displayed correctly?
I'm using the latest Z-Tree version, on Linux ElementaryOS, running on Wine.
Answer to 1: In the label of your item, do this:
<>{\rtf Payoff = \fs30 <Payoff|0.1> }
Answer to 2: I do not know for sure. I think the font z-Tree uses by default does not support those characters. What I would try is to find a font that supports them and use it. In your code the characters will appear as weird symbols, but maybe in the leafs they'll be displayed correctly.
I would like to know how to extract the metadata of an otf file. For example :
chrono number of the glyphs (ex: 001, 002...)
associated unicode in hexadecimal
etc..
Applications like "Font Examiner" can do it :
Font Examiner
Thanks in advance
If this were my problem I'd probably want to solve it using as much public and/or open source code as possible.
For example, you can use the FreeType library (which apparently compiles for both Macintosh & iOS to load the .otf font, then you can get the metadata off the loaded face (e.g. the num_glyphs attribute in FTFace_rec).
If you can load the font into a NSFont or UIFont instance, you do have access to a numberOfGlyphs and a coveredCharacterSet property (the latter shows the characters a font can render).
In Windows we can collect information about scripts supported by Font Family.
i.e.
Family Name : AdobeArabic-Regular
Script : Western
Script : Arabic
Script : Mac
How to know same thing in Mac ?
To get Styles (Bold, Bold Italic etc... ) We can use NSFontManager support.
NSArray* familyFonts = [[NSFontManager sharedFontManager] availableMembersOfFontFamily: "AdobeArabic-Regular"];
But not getting any info about Scripts..
Any solutions ?
I don’t know if this helps as it may not be the easiest way, but I hope this gets you in the right direction:
The thing you’re looking for is/are the OpenType layout tags (sometimes also called "feature tags") where a subset of these tags also defines supported scripts. These are four-character codes, like "arab" for arabic script (extended list see below). As the NSFontManager afaik doesn’t support reading these tags, I would have a look at CoreText’s CTFont framework, which provides in-depth capability of reading font properties. There I would have a look at CTFontCopyFeatures or perhaps CTFontCopyAvailableTables and CTFontCopyAttribute. I haven’t tested, but hope one of them is also capable of reading the layout/features tags.
Here you can find a list of OpenType layout tags, TrueType layout tags and the CoreText Reference.
CTFontDescriptorCopyAttribute(ctFontDescriptor, kCTFontLanguageAttribute) would be the closest one, but sadly that is about language but not script...
My project for JDE is to convert the invoice number that appear on JDE report to bar-code. Would you mind to tell me how I am able to do it? Because I am just a beginner for JDE software.
You need some kind of bar code java or jde library which you include into your project. Then you use the APIs provided by the library to convert numbers to barcode. ZXing
is one of hte libraries I know. However, I never used it with Blackberry.
A simple google after 'blackbaeery jde barcode' would give you plenty of more info.
If you install a Barcode Font you're supposed to convert any character into a barcode. But you should define what type of barcode you'll use.
http://en.wikipedia.org/wiki/Barcode#Types_of_barcodes
For 1 dimensional codes (like EAN f.e.) - you can use bar code font as recommended by
lhoffman. - Usually you need to calculate control character, add it to your string and output it in BI Publisher with barcode font.
Second approach - is kind of workaround - generate bar code as image using third party web application and include image into report (in runtime).
f.e. create simple wrapper for library like this - http://barcode-coder.com/en/barcode-php-class-203.html
it should receive invoice number as part of url and return image with proper bar code.
something like: http://..*.*/barcode/12321312312.png
shouldn't take more than 5 lines of php.
and include it in bi publisher like this: https://blogs.oracle.com/xmlpublisher/entry/dynamic_images
as advantage- you have more control on bar code and can use 2D bar codes.