Localization of the googleCast framework not working - ios

I'm trying to find a way to localize the google cast sample app.
When I look at the documentation I see that we need to set some launch options when we create the sharedInstance. So in the sample app his appdelegate I changed the setSharedInstance part to this:
let options = GCKCastOptions(discoveryCriteria: GCKDiscoveryCriteria(applicationID: kReceiverAppID))
options.physicalVolumeButtonsWillControlDeviceVolume = true
let launchOptions = GCKLaunchOptions(languageCode: "fr", relaunchIfRunning: false)
options.launchOptions = launchOptions
GCKCastContext.setSharedInstanceWith(options)
I also tried fr-FR and other language codes and also tried to set 'relaunchIfRunning' to true. But It seems that none of that is working.
Anybody succeeded in changing the language of the googlecast screens?
Kind regards,
Stef

You must localize the Setting.bundle as well. And this is done manually using text edit :(
Settings.bundle:
Root.plist
en.lproj:
Root.strings
fr.lproj:
Root.strings
en.lproj, ru.lproj folders
Root.strings - file

Add the language in your project file, that worked for me.

Related

How to get App name in UITesting swift 4 iOS

I tried to get my app name in UITesting. I tried the code below:
let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
But it gives me the nil value result.
When I was trying to find out if the 'debugDescription' provides any information about the actual app (and not the test app) I stumbled across a label that looked exactly like the app's display name.
I don't know if it helps you, but the following simple line of code helped me:
XCUIApplication().label
Are you sure, that you've set Display name in your Info.plist file?
Just set this name in Project settings or in Info.plist:
Try to go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment.
Then click over the little grey arrow under Derived data section and select your project folder to delete it.
And Product > Clean.
It helps in many situations.
I am getting app name in UI test like this:
let app = XCUIApplication()
// ...
let appName = app.label

Localized Strings are always in English in UITests (Snapshot)

I'm pretty new to Fastlane and love the idea of Snapshot, but I got a little problem.
When I'm trying to create a new set of screenshots I'm facing the problem that the UITests don't use the correct localized Strings to fetch the UI elements.
My current state is based on this Stack entries: XCode 7 UITests with localized UI
The localization method:
func localizedString(_ key: String) -> String {
let uiTestBundle = Bundle(for: MyUITests.self)
return NSLocalizedString(key, bundle: uiTestBundle, comment: "")
}
Trying to perform a tap that way:
app.navigationBars[localizedString("key_1")].buttons[localizedString("key_2")].tap()
The error I get is the following:
No matches found for "Rolling stone" NavigationBar
Rolling stone is the Base/English Localization of the key, but there should be a German one. So for any reason the UITest always picks the English Localization.
Does anybody have an idea how to troubleshoot this? I checked the SnapshotHelper and it passes a "de-DE" as the language, so that's not the point.
But I just can't find the Bug :(
Localization
This link here should be sufficient enough to solve your problem. You simple pick the correct language option during the test tab under edit scheme option.

Changing Firebase configuration at runtime on iOS

For my project, I have 2 environments:
test
prod
and 2 localizations:
en
tr
and an app for each combination: (these names do not mirror Firebase project ids)
test_en
test_tr
prod_en
prod_tr
And I have a separate plist file for each of these apps in the project, with the names Firebase-(app_type).plist ie Firebase-test_en.plist or Firebase-prod_en.plist
I am initializing FIRApp using this way:
private func ensureLoaded() {
let options = FIROptions(contentsOfFile: Bundle.main
.path(forResource: "Firebase-\(firebaseApplicationName)", ofType: "plist"))!
if nil == FIRApp(named: firebaseApplicationName) {
FIRApp.configure(withName: firebaseApplicationName, options: options)
}
}
And it seems to work ok, until I try to actually connect to firebase database, where it says:
Firebase is not configured correctly, please call [FIRApp configure]
So my question is, how do I make firebase work where I want to dynamically change configurations? There are some other questions that describe how to change configuration based on some environment variables / compiler flags but they are all referring to changing the plist file, which changes the configuration during build time, but I want to change it dynamically during runtime. Is it supported at all, is there a way to make it work?
Thanks in advance.
I found what the problem was, we were using FIRApp.auth().currentUser somewhere in the app, which returns the auth for "default" app and since we had multiple configs, we had no notion of a "default" app, so the configuration was incomplete. I changed that to FIRAuth(app: myApp)?.currentUser and it works as expected now.

IOS 8.1 localization not working,only show key not value

First of all,I did this follow this site http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014
I create a new Localizable.strings file,and localize it ,then add English and Japanese support.
I edit my Localizable.strings(en) file as follow:
"APPTITLE" = "Calibrate";
I edit my Localizable.strings(ja) file as follow:
"APPTITLE" = "こんにちわ";
At the source code,the early code :
self.title = #"PianoDisc Calibrate";
instead of :
self.title = NSLocalizedString(#"APPTITLE", nil);
Then I run it,But I get "APPTITLE" not "こんにちわ";
My environment is iPad mini,ios 8.1 system,Xcode 7 or 6.4. I'm also searched long time on the StackOverflow,like as NSLocalizedString only retrieves the key, not the value in Localizable.strings (IOS) ,I have tried the all answer,But it still not work.
There are some info,I use follow code,
NSString *path = [[NSBundle mainBundle] pathForResource:#"ja" ofType:#"lproj"];
NSLog(#"!!!!!!!!!!!!!!!!%#",path);
sometimes get null,sometimes get the true path.
What I'm missing? Thanks anyway!
I resolved it. Some guy remind that "check you haven't somehow messed up with the Build Rules (Xcode 4 -> select your target -> tab "Build Rules") There, check if you don't have too many "CopyStringsFile" rules that aren't using "CopyStringsFile". If so you can remove them all but one."
This step just resolve my problem,thanks god.

How to get Localized NSError

I have done a lot of google search without success.
I would like to use the system localization of NSError (In my case in french)
I have try many things but the wording are always in english.
The configuration off my app :
In the plist :
CFBundleDevelopmentRegion = fr_FR
In the pbxproj:
developmentRegion = fr;
knownRegions = (
fr,
Base,
);
When I call the property "localizedDescription" I always get english version like this link (NSError localizedDescription always returns english error message) but the solution doesn't work for me...
I don't found what I'm missing.
In this other link NSURLConnection returns NSError with only english as language? they copy the strings but I don't think it's the better way, we should be able to access the file without copy it.
For information when I use an UIBarButtonItem like Cancel, it's localized in french.
Thanks in advance for your help.
First you should have a localisation file with key and value strings.
Now when you want to show the localisation error, you can use following method
NSLocalizedString(<#key#>, <#comment#>)
I have had the same issue the solution was to set the info.plist attribute Localization native development region to your region: France in this case

Resources