如何使用集成在本地化中的单个.txt文件本地化按钮

时间:2015-01-06 00:58:43

标签: ios objective-c localization nslocalizedstring localizable.strings

我有一些IB动作调用特定按钮进行本地化但由于某种原因它仍然是英语。例如,这是我的#34;忘记密码"本地化按钮代码:

-(IBAction)forgetPassword:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"iProfile" message:[[Localization sharedInstance] localizedStringForKey:@"Enter Your Registered Email Address"] delegate:self cancelButtonTitle:[[Localization sharedInstance] localizedStringForKey:@"Cancel"] otherButtonTitles:[[Localization sharedInstance] localizedStringForKey:@"Send"], nil];

    alertView.alertViewStyle = UIAlertViewStylePlainTextInput;

    [alertView show];
}

其中仍然是英语,这是我的"注册"我的LoginViewController中还包含一个按钮(用户可以选择登录,注册或声明忘记的密码):

-(IBAction)signUp:(id)sender
{
    SignUpViewController *signUp = [[SignUpViewController alloc] initWithNibName:@"SignUpViewController" bundle:nil];
    [self.navigationController pushViewController:signUp animated:YES];
}

我试图弄清楚为什么我使用的这两个按钮示例在启动应用时不会本地化。我为每种语言使用.txt翻译单词页面。真的希望它能够轻松解决,欣赏时间和帮助。

这里我的本地化解释在我的LoginViewController中,其中包含以下按钮:

    -(void)customiseValues
{
    self.title = [[Localization sharedInstance] localizedStringForKey:@"Login"];
    userName.placeholder = [[Localization sharedInstance] localizedStringForKey:@"Enter Your Username"];
    password.placeholder = [[Localization sharedInstance] localizedStringForKey:@"Enter Your Password"];
    [loginButton setTitle:[[Localization sharedInstance] localizedStringForKey:@"Login"] forState:UIControlStateNormal];
    [signUpButton setTitle:[[Localization sharedInstance] localizedStringForKey:@"Sign Up"] forState:UIControlStateNormal];
    [forgetPasswordButton setTitle:[NSString stringWithFormat:@"%@?",[[Localization sharedInstance] localizedStringForKey:@"Forgot Password"]] forState:UIControlStateNormal];
}

除非另有说明,否则我已对每个按钮的每个标题进行了本地化,并将其正确放置在我的Localization.h和.m中。

0 个答案:

没有答案