Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: b15deb3881
Fetching contributors…

Cannot retrieve contributors at this time

50 lines (32 sloc) 1.34 kB
// ZPLocalization.m
// ZotPad
// Created by Rönkkö Mikko on 12/31/11.
// Copyright (c) 2011 Mikko Rönkkö. All rights reserved.
#import "ZPCore.h"
#import "ZPLocalization.h"
#import "ZPDatabase.h"
@implementation ZPLocalization
static NSCache* localizationCache = NULL;
static NSString* locale = NULL;
+ (void) dropCache{
[localizationCache removeAllObjects];
+ (NSString*) getLocalizationStringWithKey:(NSString*) key type:(NSString*) type{
if(key==NULL) return @"";
if(localizationCache == NULL) localizationCache = [[NSCache alloc] init ];
NSString* combinedKey = [type stringByAppendingString:key];
NSString* localizationString = [localizationCache objectForKey:combinedKey];
if(localizationString == NULL){
localizationString = [[ZPDatabase instance] getLocalizationStringWithKey:key type:type locale:locale];
//If there is no localizatio string available, capitalize the first letter of the key and use that.
if(localizationString == NULL){
localizationString = [key stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[key substringToIndex:1] uppercaseString]];
[localizationCache setObject:localizationString forKey:combinedKey];
return localizationString;
Jump to Line
Something went wrong with that request. Please try again.