ESTextHalfYearLocalizer Class Reference
Inherits from | NSObject |
Conforms to | ESHalfYearLocalizer ESStringLocalizer |
Declared in | ESTextHalfYearLocalizer.h ESTextHalfYearLocalizer.m |
Overview
A half year localizer that gets format strings from a given text localizer. Typically, the source is NSLocalizedString() macro.
Tasks
Other Methods
-
– init
-
– initWithStringLocalizer:firstHalfYearKey:secondHalfYearKey:yearMode:
-
halfYearLocalizer
property
Other Methods
Instance Methods
formatForFirstHalfYear
Format for the first half of the year. Only year should be parametrized.
- (NSString *)formatForFirstHalfYear
Discussion
@“%@ 年 上半期” –> @“2014 年 上半期”
@“H1 ‘%@” –> @“H1 '14”
Symbols are not escaped. They should be escaped manually prior to using in sqlite queries.
A string constant is formed by enclosing the string in single quotes (‘). A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported because they are not standard SQL. https://www.sqlite.org/lang_expr.html
Declared In
ESHalfYearLocalizer.h
formatForSecondHalfYear
Format for the second half of the year. Only year should be parametrized.
- (NSString *)formatForSecondHalfYear
Discussion
@“%@ 年 下半期” –> @“2014 年 下半期”
@“H2 ‘%@” –> @“H2 '14”
Symbols are not escaped. They should be escaped manually prior to using in sqlite queries.
A string constant is formed by enclosing the string in single quotes (‘). A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported because they are not standard SQL. https://www.sqlite.org/lang_expr.html
Declared In
ESHalfYearLocalizer.h
init
Unsupported initializer. Throws an exception.
- (instancetype)init
Return Value
nil if asserts are disabled.
Declared In
ESTextHalfYearLocalizer.h
initWithStringLocalizer:firstHalfYearKey:secondHalfYearKey:yearMode:
A designated initializer
- (instancetype)initWithStringLocalizer:(id<ESStringLocalizer>)localizer firstHalfYearKey:(NSString *)firstHalfKey secondHalfYearKey:(NSString *)secondHalfKey yearMode:(ESYearMode)yearMode
Parameters
- localizer
A key-value storage for localized strings.
- firstHalfKey
a key for the localized first half year format.
- secondHalfKey
a key for the localized second half year format.
- yearMode
ESYearModeShort or ESYearModeLong
Return Value
A properly initialized ESTextHalfYearLocalizer object.
Declared In
ESTextHalfYearLocalizer.h
localizedStringForKey:
A method to return the localized string for a given key.
- (NSString *)localizedStringForKey:(NSString *)key
Parameters
- key_
A localization key. In most cases it is a key in the “*.strings” file.
Return Value
A localized string that will be displayed to the user.
Declared In
ESStringLocalizer.h
shouldTruncateYear
A boolean value for [ESHalfYearLocalizer yearTruncationMode]
- (BOOL)shouldTruncateYear
Discussion
@return “YES” if [ESHalfYearLocalizer yearTruncationMode] is “short”. “NO” if [ESHalfYearLocalizer yearTruncationMode] is “long”.
Throws an exception for anything else.
Declared In
ESHalfYearLocalizer.h