I'm using Corona SDK but was hoping for some advice here, as I'm hoping someone can spot my error. I am trying to get the app title that appears under the icon localized.
I'm doing the following (in Corona SDK) this but I'm still not seeing the app title change under the icon when I change the "LANGUAGE" setting of my iPhone.
a) put CFBundleLocalizations in build.settings per below
settings = {
iphone =
{
plist =
{
CFBundleIconFile = "Icon.png",
CFBundleIconFiles = { << cut for this put >>},
CFBundleLocalizations = {
"English",
"French",
"Japanese",
"Chinese",
},
},
},
b) put a 'InfoPlist.strings' file for each language in a directory like 'fr.lproj' under the root. In the strings file put:
CFBundleDisplayName = “Parachutiste”;
QUESTION: Any advice or do you spot an error in what I'm doing. I must be either (a) missing something here or (b) misunderstanding how to test a change of language on my iPhone to test this? (i.e. I'm currently assuming I just change the language of the phone and this should trigger a different app title to appear under the icon)
Related
Ive run into an issue where NSLocalizedString is always returning strings capitalized regardless of its input. localization was working
and Im assuming I did something that caused this but I cannot seem
to figure out exactly what changed.
Here's my code:
func localize(_ str: String) -> String {
print("str in: \(str)")
return NSLocalizedString(str, comment: "")
}
I call it like this:
let txt = self.localize("Question")
print("txt = \(txt)")
Output:
str in: Question
txt = QUESTION
Things Ive tried:
Ive grep'd all of my .strings files and confirmed there is no
'QUESTION' in there.
Removed app from Simulator and re-run app
Changed incoming string to something that doesn't exist in any file such as 'randomxxyxxy'
Ive tried searching for quite a while on this issue and wasn't able to find anything that was like this problem.
Any help is appreciated,
Thank you
When your app is trying to localize a string but cannot find the translated text for it then it will show it in capitals. This is done to show you that the capitalized text is not localized. You can disable the capitalization of those cases by disabling the option: Show not-localized strings
This is how you do that:
Edit the scheme
Select the “Run” action and click the “Options” tab
Uncheck the “Show non-localized strings” option
In your case I think that your strings' localization is not working and so they are capitalized because that setting is activated.
I have tried to follow the below link to achieve localization .
Tutorial
It seems not working ( only English text appears )
My requirement is to change the label/button texts etc. to be changed from English to Arabic language and vice-versa on a button click inside the App.
I have already have a translated Arabic strings available from the client so I dont have to use a translation ( import/export - xliff) . Created 2 string files for English and Arabic separately and calling it ViewDidload() event checking the User had opted for Arabic/English Version.
Please note that I'm trying load the languages dynamically when user clicks button inside my app . Not by changing the device language .
For ex:
Localizable.string ( en)
"Details" = "Details";
Localizable.string(ar)
"Details" = "التفاصيل " ;
retrieval:
btnDetail.setTitle(NSLocalizedString("Details", comment: "More Details"), forState: .Normal)
But its showing only english but not Arabic when I call in buttonclick event to change to Arabic.
Please help. I m new to IOS and Swift.
Having an issue trying to use an icon font for scalable icons in a RubyMotion (ios) app.
I created a small set of icons from icomoon, and set the characters to 'A', 'B', and 'C'.
I imported this into the Font Book and it appears to respect the 'A', 'B', and 'C' characters:
To test, I fired up a word document and typed 'A', 'B', and 'C' and it appears to display fine:
Now, onto the RubyMotion app - I included the font in /resources:
(Loading Lobster and Open Sans from sub-directories work)
Then I reference the font in my Rakefile:
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'myapp'
app.fonts = ["OpenSans-Bold.ttf", "icomoon.ttf"]
end
In my controller, I add a label to the screen using the icomoon font:
#lblIcon = UILabel.alloc.initWithFrame([[0,0],[100,100]])
#lblIcon.text = "A"
#lblIcon.backgroundColor = UIColor.clearColor
#lblIcon.color = "#ffffff".to_color
ico_font = UIFont.fontWithName("icomoon", size:48)
#lblIcon.font = ico_font
self.view.addSubview #lblIcon
Now, when I run rake clean to force a refresh and rake to launch the simulator, the font doesn't seem to work:
If I use the RubyMotion inspector/REPL and drill down on the font, it say it is loading Helvetica, not icomoon as I intended:
I'm at a loss here on why I can't apply the icomoon font family and helvetica appears instead.
Any suggestions or ideas?
I have added my fonts in the 'resources' folder and successfully using them directly without manipulating app.fonts:
b.titleLabel.font = UIFont.fontWithName('Entypo', size: barHeight*1.1)
(the font I'm using is called Entypo.ttf)
Otherwise, the code you've pasted looks ok to me.
I misunderstand NSLocalizedString.
I have a project with French and English .strings files.
In project target - Localizations I have 6 files in French and English.
In english.strings file:
"hello" = "world";
In french.strings file:
"hello" = "salut";
When I write a simple line of code to change label text:
exerciseDescription.text = NSLocalizedString(#"hello", #"no comment");
Output is: hello
I changed in iOS simulator : settings - general - international - language - French/English - Done
And output is again: hello
I thought it should be world or salut...
You're using it in correct way but not added properly,
Localized filename should always be named Localizable.strings, and that file is within the particular language folder, for English, en.lproj and for French fr.lproj like wise.
You are using it right, but as #Hemang mentioned you should change your filename to Localizable.strings as this is the default.
Furthermore I would like to suggest cleaning the build folder, and removing the application from the simulator. That helped for me in one case.
Please let me know what in the following sequence is incorrect.
Somewhere in code, i have self.label.text = NSLocalizedString(#"TITLE", nil);
Localizable.strings created ( new -> Resource -> String file)
Localizable.strings (English) created // contains "TITLE" = "Hello";
Localizable.strings (Russian) created // contains "TITLE" = "Привет";
Simulator started and application deployed
Xcode closed
Simulator settings changed from English to Russian (Settings -> General -> International -> Language -> Russian)
Xcode opened
Application deployed (icon labels appear in Russian) .. when ran it says "Hello" instead of "Привет"
Am i missing a step? Did i do something in the wrong order? Please let me know
Those steps look fine. Things to try:
The folder name for Russian needs to match the language code
(ru.lproj -> Localizable.strings)
Check that the label is hooked up properly (if you're using interface builder) and not nil when you are setting self.label.text