forked from jessesquires/JSQMessagesViewController
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move strings to bundle. add bundle helper methods. jessesquires#784
- Loading branch information
1 parent
86746bd
commit 0f5cd6c
Showing
23 changed files
with
158 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Created by Jesse Squires | ||
// http://www.jessesquires.com | ||
// | ||
// | ||
// MIT License | ||
// Copyright (c) 2014 Jesse Squires | ||
// http://opensource.org/licenses/MIT | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import "NSBundle+JSQMessages.h" | ||
|
||
|
||
@interface JSQMessagesNSBundleTests : XCTestCase | ||
@end | ||
|
||
|
||
@implementation JSQMessagesNSBundleTests | ||
|
||
- (void)testMessagesBundle | ||
{ | ||
XCTAssertNotNil([NSBundle jsq_messagesBundle]); | ||
} | ||
|
||
- (void)testAssetBundle | ||
{ | ||
NSBundle *bundle = [NSBundle jsq_messagesAssetBundle]; | ||
XCTAssertNotNil(bundle); | ||
XCTAssertEqualObjects(bundle.bundlePath.lastPathComponent, @"JSQMessagesAssets.bundle"); | ||
} | ||
|
||
- (void)testLocalizedStringForKey | ||
{ | ||
XCTAssertNotNil([NSBundle jsq_localizedStringForKey:@"send"]); | ||
XCTAssertNotEqualObjects([NSBundle jsq_localizedStringForKey:@"send"], @"send"); | ||
|
||
XCTAssertNotNil([NSBundle jsq_localizedStringForKey:@"load_earlier_messages"]); | ||
XCTAssertNotEqualObjects([NSBundle jsq_localizedStringForKey:@"load_earlier_messages"], @"load_earlier_messages"); | ||
|
||
XCTAssertNotNil([NSBundle jsq_localizedStringForKey:@"new_message"]); | ||
XCTAssertNotEqualObjects([NSBundle jsq_localizedStringForKey:@"new_message"], @"new_message"); | ||
} | ||
|
||
@end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
JSQMessagesViewController/Categories/NSBundle+JSQMessages.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Created by Jesse Squires | ||
// http://www.jessesquires.com | ||
// | ||
// | ||
// Documentation | ||
// http://cocoadocs.org/docsets/JSQMessagesViewController | ||
// | ||
// | ||
// GitHub | ||
// https://github.com/jessesquires/JSQMessagesViewController | ||
// | ||
// | ||
// License | ||
// Copyright (c) 2014 Jesse Squires | ||
// Released under an MIT license: http://opensource.org/licenses/MIT | ||
// | ||
|
||
@import Foundation; | ||
|
||
@interface NSBundle (JSQMessages) | ||
|
||
/** | ||
* @return The bundle for JSQMessagesViewController. | ||
*/ | ||
+ (NSBundle *)jsq_messagesBundle; | ||
|
||
/** | ||
* @return The bundle for assets in JSQMessagesViewController. | ||
*/ | ||
+ (NSBundle *)jsq_messagesAssetBundle; | ||
|
||
/** | ||
* Returns a localized version of the string designated by the specified key and residing in the JSQMessages table. | ||
* | ||
* @param key The key for a string in the JSQMessages table. | ||
* | ||
* @return A localized version of the string designated by key in the JSQMessages table. | ||
*/ | ||
+ (NSString *)jsq_localizedStringForKey:(NSString *)key; | ||
|
||
@end |
42 changes: 42 additions & 0 deletions
42
JSQMessagesViewController/Categories/NSBundle+JSQMessages.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Created by Jesse Squires | ||
// http://www.jessesquires.com | ||
// | ||
// | ||
// Documentation | ||
// http://cocoadocs.org/docsets/JSQMessagesViewController | ||
// | ||
// | ||
// GitHub | ||
// https://github.com/jessesquires/JSQMessagesViewController | ||
// | ||
// | ||
// License | ||
// Copyright (c) 2014 Jesse Squires | ||
// Released under an MIT license: http://opensource.org/licenses/MIT | ||
// | ||
|
||
#import "NSBundle+JSQMessages.h" | ||
|
||
#import "JSQMessagesViewController.h" | ||
|
||
@implementation NSBundle (JSQMessages) | ||
|
||
+ (NSBundle *)jsq_messagesBundle | ||
{ | ||
return [NSBundle bundleForClass:[JSQMessagesViewController class]]; | ||
} | ||
|
||
+ (NSBundle *)jsq_messagesAssetBundle | ||
{ | ||
NSString *bundleResourcePath = [NSBundle jsq_messagesBundle].resourcePath; | ||
NSString *assetPath = [bundleResourcePath stringByAppendingPathComponent:@"JSQMessagesAssets.bundle"]; | ||
return [NSBundle bundleWithPath:assetPath]; | ||
} | ||
|
||
+ (NSString *)jsq_localizedStringForKey:(NSString *)key | ||
{ | ||
return NSLocalizedStringFromTableInBundle(key, @"JSQMessages", [NSBundle jsq_messagesAssetBundle], nil); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters