Before using Cordova, I used to add a dynamic parameter that detects the phone OS language and put it in the URL, so I can view the website page in the user's language.
NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
NSString *urlString = [NSString stringWithFormat: @"http://mywebsite.com/?language=%@", language];
But using Cordova forces me to load a static URL, is there anything I can do to insert the language parameter to the URL when the app starts?
Thanks.
You can create a plugin to detect the phone language with the code you are already using and on the success callback redirect to your website using javascript like this:
window.location.href = 'http://mywebsite.com/?language='+pluginResult;
You can also add this in your AppDelegate.m
inside the didFinishLaunchingWithOptions
method, right before the return
NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
self.viewController.startPage = [NSString stringWithFormat: @"http://mywebsite.com/?language=%@", language];