From f3ce8cfff32b7bbc9b46c79a19cb91a8ca02e16a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 20 May 2011 16:00:05 +0200 Subject: [PATCH] add localization framework --- Classes/LinphoneUI/LinphoneManager.m | 34 ++++++++++++------------- Classes/LinphoneUI/UICallButton.m | 12 ++++----- Classes/PhoneViewController.m | 10 ++++---- Resources/en.lproj/Localizable.strings | Bin 0 -> 5708 bytes linphone.xcodeproj/project.pbxproj | 16 ++++++++++++ 5 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 Resources/en.lproj/Localizable.strings diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index a3da09b35..c75b91f5f 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -47,7 +47,7 @@ extern void libmsamr_init(); -(void) onCall:(LinphoneCall*) currentCall StateChanged: (LinphoneCallState) new_state withMessage: (const char *) message { const char* lUserNameChars=linphone_address_get_username(linphone_call_get_remote_address(currentCall)); - NSString* lUserName = lUserNameChars?[[NSString alloc] initWithCString:lUserNameChars]:@"Unknown"; + NSString* lUserName = lUserNameChars?[[NSString alloc] initWithCString:lUserNameChars]:NSLocalizedString(@"Unknown",nil); const char* lDisplayNameChars = linphone_address_get_display_name(linphone_call_get_remote_address(currentCall)); NSString* lDisplayName = lDisplayNameChars?[[NSString alloc] initWithCString:lDisplayNameChars]:@""; @@ -82,21 +82,21 @@ extern void libmsamr_init(); //get default proxy linphone_core_get_default_proxy([LinphoneManager getLc],&proxyCfg); if (proxyCfg == nil) { - lMessage=@"Please make sure your device is connected to the internet and double check your SIP account configuration in the settings."; + lMessage=NSLocalizedString(@"Please make sure your device is connected to the internet and double check your SIP account configuration in the settings.",nil); } else { - lMessage=[NSString stringWithFormat : @"Cannot call %@",lUserName]; + lMessage=[NSString stringWithFormat : NSLocalizedString(@"Cannot call %@",nil),lUserName]; } if (message!=nil){ - lMessage=[NSString stringWithFormat : @"%@\nReason was: %s",lMessage, message]; + lMessage=[NSString stringWithFormat : NSLocalizedString(@"%@\nReason was: %s",nil),lMessage, message]; } - lTitle=@"Call failed"; + lTitle=NSLocalizedString(@"Call failed",nil); UIAlertView* error = [[UIAlertView alloc] initWithTitle:lTitle message:lMessage delegate:nil - cancelButtonTitle:@"Dismiss" + cancelButtonTitle:NSLocalizedString(@"Dismiss",nil) otherButtonTitles:nil]; [error show]; [callDelegate displayDialerFromUI:mCurrentViewController @@ -195,9 +195,9 @@ static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, Lin } else if (state == LinphoneRegistrationFailed ) { NSString* lErrorMessage=nil; if (linphone_proxy_config_get_error(cfg) == LinphoneReasonBadCredentials) { - lErrorMessage = @"Bad credentials, check your account settings"; + lErrorMessage = NSLocalizedString(@"Bad credentials, check your account settings",nil); } else if (linphone_proxy_config_get_error(cfg) == LinphoneReasonNoResponse) { - lErrorMessage = @"SIP server unreachable"; + lErrorMessage = NSLocalizedString(@"SIP server unreachable",nil); } [registrationDelegate displayRegistrationFailedFromUI:mCurrentViewController forUser:lUserName @@ -210,10 +210,10 @@ static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, Lin && linphone_proxy_config_get_error(cfg) != LinphoneReasonNoResponse) { //do not report network connection issue on registration //default behavior if no registration delegates - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Registration failure" + UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Registration failure",nil) message:lErrorMessage delegate:nil - cancelButtonTitle:@"Continue" + cancelButtonTitle:NSLocalizedString(@"Continue",nil) otherButtonTitles:nil ,nil]; [error show]; } @@ -397,11 +397,11 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach } else { if (configCheckDisable == false ) { - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Warning" - message:@"It seems you have not configured any proxy server from settings" + UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",nil) + message:NSLocalizedString(@"It seems you have not configured any proxy server from settings",nil) delegate:self - cancelButtonTitle:@"Continue" - otherButtonTitles:@"Never remind",nil]; + cancelButtonTitle:NSLocalizedString(@"Continue",nil) + otherButtonTitles:NSLocalizedString(@"Never remind",nil),nil]; [error show]; } } @@ -617,10 +617,10 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach BOOL bAudioInputAvailable= [audioSession inputIsAvailable]; if(!bAudioInputAvailable){ - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"No microphone" - message:@"You need to plug a microphone to your device to use this application." + UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"No microphone",nil) + message:NSLocalizedString(@"You need to plug a microphone to your device to use this application.",nil) delegate:nil - cancelButtonTitle:@"Ok" + cancelButtonTitle:NSLocalizedString(@"Ok",nil) otherButtonTitles:nil ,nil]; [error show]; } diff --git a/Classes/LinphoneUI/UICallButton.m b/Classes/LinphoneUI/UICallButton.m index 5e1905e71..ec015e9a8 100644 --- a/Classes/LinphoneUI/UICallButton.m +++ b/Classes/LinphoneUI/UICallButton.m @@ -24,10 +24,10 @@ @implementation UICallButton -(void) touchUp:(id) sender { if (!linphone_core_is_network_reachabled([LinphoneManager getLc])) { - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Network Error" - message:@"There is no network connection available, enable WIFI or WWAN prior to place a call" + UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Network Error",nil) + message:NSLocalizedString(@"There is no network connection available, enable WIFI or WWAN prior to place a call",nil) delegate:nil - cancelButtonTitle:@"Continue" + cancelButtonTitle:NSLocalizedString(@"Continue",nil) otherButtonTitles:nil]; [error show]; return; @@ -41,10 +41,10 @@ if ([mAddress.text hasPrefix:@"sip:"]) { linphone_core_invite([LinphoneManager getLc], [mAddress.text cStringUsingEncoding:[NSString defaultCStringEncoding]]); } else if ( proxyCfg==nil){ - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Invalid sip address" - message:@"Either configure a SIP proxy server from settings prior to place a call or use a valid sip address (I.E sip:john@example.net)" + UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Invalid sip address",nil) + message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a call or use a valid sip address (I.E sip:john@example.net)",nil) delegate:nil - cancelButtonTitle:@"Continue" + cancelButtonTitle:NSLocalizedString(@"Continue",nil) otherButtonTitles:nil]; [error show]; diff --git a/Classes/PhoneViewController.m b/Classes/PhoneViewController.m index 0e1432f29..76c226cb6 100644 --- a/Classes/PhoneViewController.m +++ b/Classes/PhoneViewController.m @@ -215,7 +215,7 @@ [self displayIncalViewforUser:username withDisplayName:displayName]; [call setEnabled:false]; - [callDuration setText:@"Calling..."]; + [callDuration setText:NSLocalizedString(@"Calling...",nil)]; [speaker reset]; } @@ -244,17 +244,17 @@ if (notif) { notif.repeatInterval = 0; - notif.alertBody =[NSString stringWithFormat:@" %@ is calling you",username]; + notif.alertBody =[NSString stringWithFormat:NSLocalizedString(@" %@ is calling you",nil),username]; notif.alertAction = @"Answer"; notif.soundName = @"oldphone-mono-30s.caf"; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } } else { - mIncomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:@" %@ is calling you",username] + mIncomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@" %@ is calling you",nil),username] delegate:self - cancelButtonTitle:@"Decline" - destructiveButtonTitle:@"Answer" + cancelButtonTitle:NSLocalizedString(@"Decline",nil) + destructiveButtonTitle:NSLocalizedString(@"Answer",nil) otherButtonTitles:nil]; mIncomingCallActionSheet.actionSheetStyle = UIActionSheetStyleDefault; [mIncomingCallActionSheet showInView:self.view]; diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..43899b43f750d6e1a166be433473903483f7d48a GIT binary patch literal 5708 zcmd^D?{5-85S`EcD=tP7Z48ZmtT8ECO!}oZYC}x?f(NAt9E9Ua`_HTI&1AdV1B4pK zA89Tedwa7xZ)a!T%-;8J2eL1joXQmU9QO&Xz7(>+^GxRGxssvu(APuH7rDWm?+55D z(CR~`iN1X~kUe>XRzr?(A4-XPE?pVpqU-?AH<+(dsaJT~Rr)1n-oyOA7b$Um2Cny5 zLlZ?cx%<`+NrBy->V5~-F)oTeOY3Zw@~HKlzkaVTG*=MrlC!#;4omg);BE4P&aw#)xXwC00zAfxxBys#eas=N={6Cm0i6Ol!CmG?p$>Wez*o?Sv;}AYl9QX!}EmQekS9G zD&z%nG;>%1zK**=OzS1Q5Hafz2P@?%eCZN*W`Y#cW*Hw;?@*OT{r2Re=}hZjvM)34 z1Ti(zR(YG{BTMrX!4s`z=Wt4;wP>$gd7W`-ncQjzo@N8%Q;M<1xTRbVmacFv=E;l| z#=7%Js4wd0l6pPT#muZEcn+mTqTqb1RYzK9Kg`wpcoM$_@XJOC%g?dLaX-R&%j(AH z*SnAKK^%PRZoSHrFS&^x$4q4Y8ByPFln?Tc>f1yaz7{c4GG8*nBI{d}gy;pp@S9?1iiFqe{XW_| z*j3i5WW_i_@% literal 0 HcmV?d00001 diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 27789a338..fad2101df 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 220FAD3810765B400068D98F /* libspeex.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD2F10765B400068D98F /* libspeex.a */; }; 220FAD3910765B400068D98F /* libspeexdsp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD3010765B400068D98F /* libspeexdsp.a */; }; 220FAE4B10767A6A0068D98F /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 220FAE4A10767A6A0068D98F /* PhoneMainView.xib */; }; + 2214783D1386A2030020F8B8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2214783B1386A2030020F8B8 /* Localizable.strings */; }; 2214EB7A12F846B1002A5394 /* UICallButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EB7912F846B1002A5394 /* UICallButton.m */; }; 2214EB8912F84EBB002A5394 /* UIHangUpButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EB8812F84EBB002A5394 /* UIHangUpButton.m */; }; 2214EBDA12F8558F002A5394 /* UIToggleButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EBD912F8558F002A5394 /* UIToggleButton.m */; }; @@ -229,6 +230,7 @@ 220FAD2F10765B400068D98F /* libspeex.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeex.a; path = "liblinphone-sdk/apple-darwin/lib/libspeex.a"; sourceTree = ""; }; 220FAD3010765B400068D98F /* libspeexdsp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeexdsp.a; path = "liblinphone-sdk/apple-darwin/lib/libspeexdsp.a"; sourceTree = ""; }; 220FAE4A10767A6A0068D98F /* PhoneMainView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PhoneMainView.xib; sourceTree = ""; }; + 2214783C1386A2030020F8B8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localizable.strings; sourceTree = ""; }; 2214EB7812F846B1002A5394 /* UICallButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICallButton.h; sourceTree = ""; }; 2214EB7912F846B1002A5394 /* UICallButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICallButton.m; sourceTree = ""; }; 2214EB8712F84EBB002A5394 /* UIHangUpButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIHangUpButton.h; sourceTree = ""; }; @@ -776,6 +778,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + 2214783B1386A2030020F8B8 /* Localizable.strings */, 22A10D9E11F88C1F00373793 /* liblinphone.xcodeproj */, 223148E51178A09900637D6A /* libmsilbc.a */, 223148E31178A08200637D6A /* libilbc.a */, @@ -899,6 +902,7 @@ Japanese, French, German, + en, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; @@ -960,6 +964,7 @@ 222A483412F7176F0075F07F /* IncallViewController.xib in Resources */, 2218A92612FBE1340088A667 /* FirstLoginViewController.xib in Resources */, 228B19AF130290C500F154D3 /* iTunesArtwork in Resources */, + 2214783D1386A2030020F8B8 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -994,6 +999,17 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXVariantGroup section */ + 2214783B1386A2030020F8B8 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 2214783C1386A2030020F8B8 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration;