ios应用程序中的urdu语言支持

时间:2013-10-24 07:07:59

标签: ios iphone xcode language-features

我想创建一个包含文本集合的应用程序,但在URDU语言中,我很困惑如何实现它。我已经阅读了很多关于此的帖子,但无法得出相关答案。请帮我解决这个问题。提前致谢

这是我获取数据的代码:

+ (void) fetchData:(NSManagedObjectContext *)context
{

NSString *dbFilePath = [[NSBundle mainBundle] pathForResource:DATABASE_NAME ofType:@"sqlite"];

sqlite3 *database;
if (sqlite3_open([dbFilePath UTF8String], &database) != SQLITE_OK)
    NSLog(@"sqlite3_open: failed");
else
{
    NSString *nsquery = [[NSString alloc] initWithFormat:@"SELECT * FROM myTable"];
    const char *query = [nsquery UTF8String];
    sqlite3_stmt *statement;
    int prepareCode = sqlite3_prepare_v2(database, query, -1, &statement, NULL);
    if(prepareCode == 0) {
        myClass *aObject;

        while (sqlite3_step(statement) == SQLITE_ROW)
        {
            aObject = [NSEntityDescription insertNewObjectForEntityForName:@"myClass" inManagedObjectContext:context];
            aObject.surah_id = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 0) encoding:NSUTF8StringEncoding];
            aObject.arabic_name = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 1) encoding:NSUTF8StringEncoding];
            aObject.number_of_ayaat = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 2) encoding:NSUTF8StringEncoding];
        }

        sqlite3_finalize(statement);
    }

    NSError *error = nil;
    if (![context save:&error])
        NSLog(@"error occured while saving: %@",error.description);
    NSError *err;
    NSFileManager *filemgr = [[NSFileManager alloc] init];
    [filemgr removeItemAtPath:dbFilePath error:&err];
    NSLog(@"Deleted sqlite3 database");
}
}

1 个答案:

答案 0 :(得分:0)

这很容易。

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {
    [[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"ar", nil] forKey:@"AppleLanguages"];
   }

然后只需将应用程序的阿拉伯数据复制并粘贴到NIB文件中即可。或代码中的字符串。 注意:这样用户只需在首次运行时重启App一次。