This commit is contained in:
Alexandre Wilhelm
2015-10-02 11:10:01 -07:00
25 changed files with 1556 additions and 59 deletions
+17 -17
View File
@@ -32,6 +32,7 @@
@import "_CPCibObjectData.j"
@import "_CPCibProxyObject.j"
@import "_CPCibWindowTemplate.j"
@import "_CPLocalizableString.j"
CPCibOwner = @"CPCibOwner";
CPCibTopLevelObjects = @"CPCibTopLevelObjects";
@@ -46,10 +47,11 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
@implementation CPCib : CPObject
{
CPData _data;
CPBundle _bundle;
BOOL _awakenCustomResources;
BOOL _awakenCustomResources @accessors(property=_awakenCustomResources);
CPBundle _bundle;
CPData _data;
CPString _cibName;
id _loadDelegate;
}
@@ -59,6 +61,8 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
if (self)
{
_cibName = [aURL lastPathComponent];
_data = [CPURLConnection sendSynchronousRequest:[CPURLRequest requestWithURL:aURL] returningResponse:nil];
if (!_data)
@@ -76,6 +80,8 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
if (self)
{
_cibName = [aURL lastPathComponent];
[CPURLConnection connectionWithRequest:[CPURLRequest requestWithURL:aURL] delegate:self];
_awakenCustomResources = YES;
@@ -92,7 +98,9 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
aName = [aName stringByAppendingString:@".cib"];
// If aBundle is nil, use mainBundle, but ONLY for searching for the nib, not for resources later.
self = [self initWithContentsOfURL:[aBundle || [CPBundle mainBundle] pathForResource:aName]];
var bundle = aBundle || [CPBundle mainBundle];
self = [self initWithContentsOfURL:[bundle _cibPathForResource:aName]];
if (self)
_bundle = aBundle;
@@ -106,7 +114,9 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
aName = [aName stringByAppendingString:@".cib"];
// If aBundle is nil, use mainBundle, but ONLY for searching for the nib, not for resources later.
self = [self initWithContentsOfURL:[aBundle || [CPBundle mainBundle] pathForResource:aName] loadDelegate:aLoadDelegate];
var bundle = aBundle || [CPBundle mainBundle];
self = [self initWithContentsOfURL:[bundle _cibPathForResource:aName] loadDelegate:aLoadDelegate];
if (self)
_bundle = aBundle;
@@ -114,16 +124,6 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
return self;
}
- (void)_setAwakenCustomResources:(BOOL)shouldAwakenCustomResources
{
_awakenCustomResources = shouldAwakenCustomResources;
}
- (BOOL)_awakenCustomResources
{
return _awakenCustomResources;
}
- (BOOL)instantiateCibWithExternalNameTable:(CPDictionary)anExternalNameTable
{
var bundle = _bundle,
@@ -132,7 +132,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
if (!bundle && owner)
bundle = [CPBundle bundleForClass:[owner class]];
var unarchiver = [[_CPCibKeyedUnarchiver alloc] initForReadingWithData:_data bundle:bundle awakenCustomResources:_awakenCustomResources],
var unarchiver = [[_CPCibKeyedUnarchiver alloc] initForReadingWithData:_data bundle:bundle awakenCustomResources:_awakenCustomResources cibName:_cibName],
replacementClasses = [anExternalNameTable objectForKey:CPCibReplacementClasses];
if (replacementClasses)
@@ -226,4 +226,4 @@ var CPCibDataFileKey = @"CPCibDataFileKey",
[aCoder encodeObject:[_data base64] forKey:CPCibDataFileKey];
}
@end
@end
+20 -10
View File
@@ -26,7 +26,11 @@
@import "CPCib.j"
var CPCibOwner = @"CPCibOwner";
var CPCibOwner = @"CPCibOwner",
CPBundleDefaultLanguage = @"CPBundleDefaultLanguage",
CPBundleTypeOfLocalization = @"CPBundleTypeOfLocalization",
CPBundleBaseLocalizationType = @"CPBundleBaseLocalizationType",
CPBundleInterfaceBuilderLocalizationType = @"CPBundleInterfaceBuilderLocalizationType";
@implementation CPObject (CPCibLoading)
@@ -45,14 +49,7 @@ var CPCibOwner = @"CPCibOwner";
+ (CPCib)loadCibNamed:(CPString)aName owner:(id)anOwner
{
if (![aName hasSuffix:@".cib"])
aName = [aName stringByAppendingString:@".cib"];
// Path is based solely on anOwner:
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle],
path = [bundle pathForResource:aName];
return [self loadCibFile:path externalNameTable:@{ CPCibOwner: anOwner }];
return [self loadCibNamed:aName owner:anOwner loadDelegate:nil];
}
- (CPCib)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable
@@ -76,7 +73,7 @@ var CPCibOwner = @"CPCibOwner";
// Path is based solely on anOwner:
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle],
path = [bundle pathForResource:aName];
path = [bundle _cibPathForResource:aName];
return [self loadCibFile:path externalNameTable:@{ CPCibOwner: anOwner } loadDelegate:aDelegate];
}
@@ -91,6 +88,19 @@ var CPCibOwner = @"CPCibOwner";
externalNameTable:aNameTable]]);
}
- (CPString)_cibPathForResource:(CPString)aName
{
var defaultBundleLanguage = [self objectForInfoDictionaryKey:CPBundleDefaultLanguage],
typeOfLocalization = [self objectForInfoDictionaryKey:CPBundleTypeOfLocalization];
if (defaultBundleLanguage && (!typeOfLocalization || typeOfLocalization == CPBundleBaseLocalizationType))
aName = @"Base.lproj/" + aName;
else if (defaultBundleLanguage && typeOfLocalization == CPBundleInterfaceBuilderLocalizationType)
aName = _bundle.loadedLanguage() + ".lproj/" + aName;
return [self pathForResource:aName];
}
@end
@implementation _CPCibLoadDelegate : CPObject
+10 -18
View File
@@ -25,12 +25,18 @@
@implementation _CPCibKeyedUnarchiver : CPKeyedUnarchiver
{
CPBundle _bundle;
BOOL _awakenCustomResources;
CPDictionary _externalObjectsForProxyIdentifiers;
BOOL _awakenCustomResources @accessors(getter=awakenCustomResources);
CPBundle _bundle @accessors(getter=bundle);
CPDictionary _externalObjectsForProxyIdentifiers @accessors(setter=setExternalObjectsForProxyIdentifiers:);
CPString _cibName @accessors(getter=cibName);
}
- (id)initForReadingWithData:(CPData)data bundle:(CPBundle)aBundle awakenCustomResources:(BOOL)shouldAwakenCustomResources
{
return [self initForReadingWithData:data bundle:aBundle awakenCustomResources:shouldAwakenCustomResources cibName:@""];
}
- (id)initForReadingWithData:(CPData)data bundle:(CPBundle)aBundle awakenCustomResources:(BOOL)shouldAwakenCustomResources cibName:(CPString)aCibName
{
self = [super initForReadingWithData:data];
@@ -38,6 +44,7 @@
{
_bundle = aBundle;
_awakenCustomResources = shouldAwakenCustomResources;
_cibName = aCibName;
[self setDelegate:self];
}
@@ -45,21 +52,6 @@
return self;
}
- (CPBundle)bundle
{
return _bundle;
}
- (BOOL)awakenCustomResources
{
return _awakenCustomResources;
}
- (void)setExternalObjectsForProxyIdentifiers:(CPDictionary)externalObjectsForProxyIdentifiers
{
_externalObjectsForProxyIdentifiers = externalObjectsForProxyIdentifiers;
}
- (id)externalObjectForProxyIdentifier:(CPString)anIdentifier
{
return [_externalObjectsForProxyIdentifiers objectForKey:anIdentifier];
+62
View File
@@ -0,0 +1,62 @@
/*
* _CPLocalizableString.j
* AppKit
*
* Created by Alexandre Wilhelm.
* Copyright 2015, Cappuccino Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPString.j>
@import <Foundation/CPCharacterSet.j>
@implementation _CPLocalizableString : CPObject
{
CPString _dev @accessors(property=dev);
CPString _key @accessors(property=key);
CPString _value @accessors(property=value);
}
@end
var CPLocalizableStringDev = @"CPLocalizableStringDev",
CPLocalizableStringKey = @"CPLocalizableStringKey",
CPLocalizableStringValue = @"CPLocalizableStringValue";
@implementation _CPLocalizableString (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
[self init];
_dev = [aCoder decodeObjectForKey:CPLocalizableStringDev];
_key = [aCoder decodeObjectForKey:CPLocalizableStringKey];
_value = [aCoder decodeObjectForKey:CPLocalizableStringValue];
var tableName = [[aCoder cibName] stringByTrimmingCharactersInSet:[CPCharacterSet characterSetWithCharactersInString:@".cib"]];
return [[aCoder bundle] localizedStringForKey:_key value:_value table:tableName];
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_dev forKey:CPLocalizableStringDev];
[aCoder encodeObject:_key forKey:CPLocalizableStringKey];
[aCoder encodeObject:_value forKey:CPLocalizableStringValue];
}
@end
+58 -3
View File
@@ -25,8 +25,18 @@
@import "CPNotificationCenter.j"
@import "CPObject.j"
@global CFBundleCopyBundleLocalizations
@global CFBundleCopyLocalizedString
CPBundleDidLoadNotification = @"CPBundleDidLoadNotification";
@protocol CPBundleDelegate <CPObject>
@required
- (void)bundleDidFinishLoading:(CPBundle)aBundle;
@end
/*!
@class CPBundle
@ingroup foundation
@@ -37,8 +47,8 @@ var CPBundlesForURLStrings = { };
@implementation CPBundle : CPObject
{
CFBundle _bundle;
id _delegate;
CFBundle _bundle;
id <CPBundleDelegate> _delegate;
}
+ (CPBundle)bundleWithURL:(CPURL)aURL
@@ -94,6 +104,7 @@ var CPBundlesForURLStrings = { };
if (self)
{
_bundle = new CFBundle(aURL);
CPBundlesForURLStrings[URLString] = self;
}
@@ -154,6 +165,21 @@ var CPBundlesForURLStrings = { };
return _bundle.pathForResource(aFilename);
}
- (CPString)pathForResource:(CPString)aFilename ofType:(CPString)extension
{
return _bundle.pathForResource(aFilename, extension);
}
- (CPString)pathForResource:(CPString)aFilename ofType:(CPString)extension inDirectory:(CPString)subpath
{
return _bundle.pathForResource(aFilename, extension, subpath);
}
- (CPString)pathForResource:(CPString)aFilename ofType:(CPString)extension inDirectory:(CPString)subpath forLocalization:(CPString)localizationName
{
return _bundle.pathForResource(aFilename, extension, subpath, localizationName);
}
- (CPDictionary)infoDictionary
{
return _bundle.infoDictionary();
@@ -164,7 +190,7 @@ var CPBundlesForURLStrings = { };
return _bundle.valueForInfoDictionaryKey(aKey);
}
- (void)loadWithDelegate:(id)aDelegate
- (void)loadWithDelegate:(id <CPBundleDelegate>)aDelegate
{
_delegate = aDelegate;
@@ -212,4 +238,33 @@ var CPBundlesForURLStrings = { };
return [super description] + "(" + [self bundlePath] + ")";
}
#pragma mark -
#pragma mark Localization
- (CPArray)localizations
{
return CFBundleCopyBundleLocalizations(_bundle);
}
- (CPString)localizedStringForKey:(CPString)aKey value:(CPString)aValue table:(CPString)aTable
{
return CFBundleCopyLocalizedString(_bundle, aKey, aValue, aTable);
}
@end
function CPLocalizedString(key, comment)
{
return CFCopyLocalizedString(key, comment);
}
function CPLocalizedStringFromTable(key, table, comment)
{
return CFCopyLocalizedStringFromTable(key, table, comment);
}
function CPCopyLocalizedStringFromTableInBundle(key, table, bundle, comment)
{
return CFCopyLocalizedStringFromTableInBundle(key, table, bundle._bundle, comment);
}
+188 -11
View File
@@ -20,20 +20,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
var CFBundleUnloaded = 0,
CFBundleLoading = 1 << 0,
CFBundleLoadingInfoPlist = 1 << 1,
CFBundleLoadingExecutable = 1 << 2,
CFBundleLoadingSpritedImages = 1 << 3,
CFBundleLoaded = 1 << 4;
var CFBundleUnloaded = 0,
CFBundleLoading = 1 << 0,
CFBundleLoadingInfoPlist = 1 << 1,
CFBundleLoadingExecutable = 1 << 2,
CFBundleLoadingSpritedImages = 1 << 3,
CFBundleLoadingLocalizableStrings = 1 << 4,
CFBundleLoaded = 1 << 5;
var CFBundlesForURLStrings = { },
CFBundlesForClasses = { },
CFBundlesWithIdentifiers = { },
CFCacheBuster = new Date().getTime(),
CFTotalBytesLoaded = 0,
CFCacheBuster = new Date().getTime(),
CFTotalBytesLoaded = 0,
CPApplicationSizeInBytes = 0;
var CPBundleDefaultBrowserLanguage = "CPBundleDefaultBrowserLanguage",
CPBundleDefaultLanguage = "CPBundleDefaultLanguage";
GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
{
aURL = makeAbsoluteURL(aURL).asDirectoryPathURL();
@@ -58,6 +62,9 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
this._infoDictionary = new CFDictionary();
this._eventDispatcher = new EventDispatcher(this);
this._localizableStrings = [];
this._loadedLanguage = NULL;
}
DISPLAY_NAME(CFBundle);
@@ -145,11 +152,14 @@ CFBundle.prototype.resourcesDirectoryURL = function()
DISPLAY_NAME(CFBundle.prototype.resourcesDirectoryURL);
CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ aType, /*String*/ aSubDirectory)
CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ aType, /*String*/ aSubDirectory, /*String*/ localizationName)
{
if (aType)
aResourceName = aResourceName + "." + aType;
if (localizationName)
aResourceName = localizationName + aResourceName;
if (aSubDirectory)
aResourceName = aSubDirectory + "/" + aResourceName;
@@ -194,6 +204,11 @@ CFBundle.prototype.infoDictionary = function()
DISPLAY_NAME(CFBundle.prototype.infoDictionary);
CFBundle.prototype.loadedLanguage = function()
{
return this._loadedLanguage;
};
CFBundle.prototype.valueForInfoDictionaryKey = function(/*String*/ aKey)
{
return this._infoDictionary.valueForKey(aKey);
@@ -318,6 +333,7 @@ CFBundle.prototype.load = function(/*BOOL*/ shouldExecute)
if (self === CFBundle.mainBundle() && self.valueForInfoDictionaryKey("CPApplicationSize"))
CPApplicationSizeInBytes = self.valueForInfoDictionaryKey("CPApplicationSize").valueForKey("executable") || 0;
loadLanguageForBundle(self);
loadExecutableAndResources(self, shouldExecute);
}
@@ -354,6 +370,7 @@ function loadExecutableAndResources(/*Bundle*/ aBundle, /*BOOL*/ shouldExecute)
loadExecutableForBundle(aBundle, success, failure, progress);
loadSpritedImagesForBundle(aBundle, success, failure, progress);
loadLocalizableStringsForBundle(aBundle, success, failure, progress);
if (aBundle._loadStatus === CFBundleLoading)
return success();
@@ -490,6 +507,120 @@ function loadSpritedImagesForBundle(/*Bundle*/ aBundle, success, failure, progre
}, failure, progress);
}
function loadLocalizableStringsForBundle(/*Bundle*/ aBundle, success, failure, progress)
{
var language = aBundle._loadedLanguage;
if (!language)
return;
var localizableStrings = aBundle.valueForInfoDictionaryKey("CPBundleLocalizableStrings");
if (!localizableStrings)
return;
var self = aBundle,
length = localizableStrings.length,
languagePathURL = new CFURL(language + ".lproj/", self.resourcesDirectoryURL()),
fileSuccessed = 0;
for (var i = 0; i < length; i++)
{
var localizableString = localizableStrings[i];
function onsuccess(/*Event*/ anEvent)
{
var contentFile = anEvent.request.responseText(),
tableName = new CFURL(anEvent.request._URL).lastPathComponent();
try
{
loadLocalizableContentForFileInBundle(self, contentFile, tableName);
if (++fileSuccessed == length)
{
aBundle._loadStatus &= ~CFBundleLoadingLocalizableStrings;
success();
}
}
catch(e)
{
failure(new Error("Error when parsing the localizable file " + tableName));
}
}
aBundle._loadStatus |= CFBundleLoadingLocalizableStrings;
new FileRequest(new CFURL(localizableString, languagePathURL), onsuccess, failure, progress);
}
}
function loadLocalizableContentForFileInBundle(bundle, contentFile, tableName)
{
var values = {},
lines = contentFile.split("\n"),
currentContext;
bundle._localizableStrings[tableName] = values;
for (var i = 0; i < lines.length; i++)
{
var line = lines[i];
// Context
if (line[0] == "/")
{
currentContext = line.substring(2, line.length - 2).trim();
continue;
}
// Key
if (line[0] == "\"")
{
var split = line.split("\"")
// Here we add twice the translated value, once with the context and once without
// This will help in term of rapidity when asking the value of the key
var key = split[1];
if (!(key in values))
values[key] = split[3];
key += currentContext;
if (!(key in values))
values[key] = split[3];
continue;
}
}
}
function loadLanguageForBundle(aBundle)
{
if (aBundle._loadedLanguage)
return;
var defaultLanguage = aBundle.valueForInfoDictionaryKey(CPBundleDefaultLanguage);
if (defaultLanguage != CPBundleDefaultBrowserLanguage && defaultLanguage)
{
aBundle._loadedLanguage = defaultLanguage;
return;
}
if (typeof navigator == "undefined")
return;
// userLanguage is an IE only property.
var language = (typeof navigator.language !== "undefined") ? navigator.language : navigator.userLanguage;
if (!language)
return;
aBundle._loadedLanguage = language.substring(0, 2);
}
var CFBundleSpriteSupportListeners = [],
CFBundleSupportedSpriteType = -1,
CFBundleNoSpriteType = 0,
@@ -734,7 +865,53 @@ CFBundle.prototype.path = function()
return this.bundlePath.apply(this, arguments);
};
CFBundle.prototype.pathForResource = function(aResource)
CFBundle.prototype.pathForResource = function(aResource, aType, aSubDirectory, localizationName)
{
return this.resourceURL(aResource).absoluteString();
return this.resourceURL(aResource, aType, aSubDirectory, localizationName).absoluteString();
};
GLOBAL(CFBundleCopyLocalizedString) = function (/*Bundle*/ bundle, key, value, tableName)
{
return CFCopyLocalizedStringWithDefaultValue(key, tableName, bundle, value, "");
}
GLOBAL(CFBundleCopyBundleLocalizations) = function (/*Bundle*/ aBundle)
{
return [this._loadedLanguage];
}
GLOBAL(CFCopyLocalizedString) = function (key, comment)
{
return CFCopyLocalizedStringFromTable(key, "Localizable", comment);
}
GLOBAL(CFCopyLocalizedStringFromTable) = function (key, tableName, comment)
{
return CFCopyLocalizedStringFromTableInBundle(key, tableName, CFBundleGetMainBundle(), comment);
}
GLOBAL(CFCopyLocalizedStringFromTableInBundle) = function (key, tableName, bundle, comment)
{
return CFCopyLocalizedStringWithDefaultValue(key, tableName, bundle, null, comment);
}
GLOBAL(CFCopyLocalizedStringWithDefaultValue) = function (key, tableName, bundle, value, comment)
{
var string;
if (!tableName)
tableName = "Localizable";
tableName += ".strings";
var localizableString = bundle._localizableStrings[tableName];
string = localizableString ? localizableString[key + comment] : null;
return string || (value || key);
}
GLOBAL(CFBundleGetMainBundle) = function ()
{
return CFBundle.mainBundle();
}
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>BundleTest</string>
<key>CPBundleLocalizableStrings</key>
<array>
<string>Localizable.strings</string>
</array>
<key>CPBundleDefaultLanguage</key>
<string>fr</string>
</dict>
</plist>
@@ -0,0 +1,5 @@
/* My first context. */
"Label from file" = "Label traduit de fr.lproj du premier context";
/* My second context. */
"Label from file" = "Label traduit de fr.lproj du second context";
+69
View File
@@ -0,0 +1,69 @@
@import <Foundation/CPBundle.j>
@implementation CPBundleTest : OJTestCase
{
}
+ (void)setUp
{
}
+ (void)tearDown
{
}
- (void)setUp
{
}
- (void)tearDown
{
}
- (void)testCreationMainBundle
{
var bundle = [CPBundle mainBundle];
}
- (void)testLoadingBundle
{
var bundle = [CPBundle bundleWithPath:@"Tests/Foundation/BundleTest"];
[bundle loadWithDelegate:self];
[self assert:[bundle objectForInfoDictionaryKey:"CPBundleDefaultLanguage"] equals:"fr"];
[self assert:[bundle objectForInfoDictionaryKey:"CPBundleLocalizableStrings"] equals:["Localizable.strings"]];
}
- (void)testLocalization
{
var bundle = [CPBundle bundleWithPath:@"Tests/Foundation/BundleTest"];
[bundle loadWithDelegate:self];
[self assert:[bundle localizedStringForKey:"Label from file" value:"" table:"Localizable"] equals:"Label traduit de fr.lproj du premier context"];
[self assert:[bundle localizedStringForKey:"Wrong key" value:"Default value" table:"Localizable"] equals:"Default value"];
[self assert:[bundle localizedStringForKey:"Wrong key" value:"" table:"Localizable"] equals:"Wrong key"];
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "Localizable", bundle, "My first context.") equals:"Label traduit de fr.lproj du premier context"];
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "", bundle, "My first context.") equals:"Label traduit de fr.lproj du premier context"];
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "Localizable", bundle, "") equals:"Label traduit de fr.lproj du premier context"];
[self assert:CPCopyLocalizedStringFromTableInBundle("Wrong key", "Localizable", bundle, "") equals:"Wrong key"];
[self assert:CPCopyLocalizedStringFromTableInBundle("Wrong key", "coucou", bundle, "") equals:"Wrong key"];
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "Localizable", bundle, "My second context.") equals:"Label traduit de fr.lproj du second context"];
}
@end
@implementation CPBundleTest (CPBundleTestBundleDelegate)
- (void)bundleDidFinishLoading:(CPBundle)aBundle
{
}
@end
@@ -0,0 +1,53 @@
/*
* AppController.j
* CPLocalizationTest
*
* Created by You on April 20, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@implementation AppController : CPObject
{
@outlet CPWindow theWindow;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
var label = [CPTextField labelWithTitle:CPLocalizedString(@"Label from file", @"") + " -> Label title from en.lproj from first context"];
[label setFrameOrigin:CGPointMake(20, 10)];
[[theWindow contentView] addSubview:label];
var label2 = [CPTextField labelWithTitle:CPLocalizedString(@"Label from file", @"My second context.") + " -> Label title from en.lproj from second context"];
[label2 setFrameOrigin:CGPointMake(20, 30)];
[[theWindow contentView] addSubview:label2];
var label3 = [CPTextField labelWithTitle:CPLocalizedString(@"Label from file", @"My first context.") + " -> Label title from en.lproj from first context"];
[label3 setFrameOrigin:CGPointMake(20, 50)];
[[theWindow contentView] addSubview:label3];
var label4 = [CPTextField labelWithTitle:CPLocalizedStringFromTable(@"Label from file", @"SecondLocalizable", @"My first context.") + " -> Label title from first context from en.lproj from SecondLocalizable"];
[label4 setFrameOrigin:CGPointMake(20, 70)];
[[theWindow contentView] addSubview:label4];
var label5 = [CPTextField labelWithTitle:CPLocalizedString(@"Wrong key", @"") + " -> Wrong key"];
[label5 setFrameOrigin:CGPointMake(20, 90)];
[[theWindow contentView] addSubview:label5];
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
}
@end
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>CPLocalizationTest</string>
<key>CPBundleVersion</key>
<string>1.0</string>
<key>CPHumanReadableCopyright</key>
<string>Copyright © 2015, Your Company All rights reserved.</string>
<key>CPBundleLocalizableStrings</key>
<array>
<string>Localizable.strings</string>
<string>SecondLocalizable.strings</string>
<string>MainMenu.strings</string>
</array>
<key>CPBundleTypeOfLocalization</key>
<string>CPBundleBaseLocalizationType</string>
<key>CPBundleDefaultLanguage</key>
<string>en</string>
</dict>
</plist>
+184
View File
@@ -0,0 +1,184 @@
/*
* Jakefile
* CPLocalizationTest
*
* Created by You on April 20, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os"),
projectName = "CPLocalizationTest";
app (projectName, function(task)
{
ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks";
if (configuration === "Debug")
ENV["OBJJ_INCLUDE_PATHS"] = FILE.join(ENV["OBJJ_INCLUDE_PATHS"], configuration);
task.setBuildIntermediatesPath(FILE.join("Build", "CPLocalizationTest.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPLocalizationTest");
task.setIdentifier("com.yourcompany.CPLocalizationTest");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPLocalizationTest");
task.setSources(new FileList("**/*.j").exclude(FILE.join("Build", "**")).exclude(FILE.join("Frameworks", "Source", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", [projectName], function()
{
printResults(configuration);
});
task ("build", ["default"], function()
{
updateApplicationSize();
});
task ("debug", function()
{
configuration = ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
configuration = ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", projectName, "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", projectName, "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", projectName));
OS.system(["press", "-f", FILE.join("Build", "Release", projectName), FILE.join("Build", "Deployment", projectName)]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", projectName));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", projectName), FILE.join("Build", "Desktop", projectName, "CPLocalizationTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", projectName, "CPLocalizationTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, projectName));
print("----------------------------");
}
function updateApplicationSize()
{
print("Calculating application file sizes...");
var contents = FILE.read(FILE.join("Build", configuration, projectName, "Info.plist"), { charset:"UTF-8" }),
format = CFPropertyList.sniffedFormatOfString(contents),
plist = CFPropertyList.propertyListFromString(contents),
totalBytes = {executable:0, data:0, mhtml:0};
// Get the size of all framework executables and sprite data
var frameworksDir = "Frameworks";
if (configuration === "Debug")
frameworksDir = FILE.join(frameworksDir, "Debug");
var frameworks = FILE.list(frameworksDir);
frameworks.forEach(function(framework)
{
if (framework !== "Source")
addBundleFileSizes(FILE.join(frameworksDir, framework), totalBytes);
});
// Read in the default theme name, and attempt to get its size
var themeName = plist.valueForKey("CPDefaultTheme") || "Aristo2",
themePath = nil;
if (themeName === "Aristo" || themeName === "Aristo2")
themePath = FILE.join(frameworksDir, "AppKit", "Resources", themeName + ".blend");
else
themePath = FILE.join("Frameworks", "Resources", themeName + ".blend");
if (FILE.isDirectory(themePath))
addBundleFileSizes(themePath, totalBytes);
// Add sizes for the app
addBundleFileSizes(FILE.join("Build", configuration, projectName), totalBytes);
print("Executables: " + totalBytes.executable + ", sprite data: " + totalBytes.data + ", total: " + (totalBytes.executable + totalBytes.data));
var dict = new CFMutableDictionary();
dict.setValueForKey("executable", totalBytes.executable);
dict.setValueForKey("data", totalBytes.data);
dict.setValueForKey("mhtml", totalBytes.mhtml);
plist.setValueForKey("CPApplicationSize", dict);
FILE.write(FILE.join("Build", configuration, projectName, "Info.plist"), CFPropertyList.stringFromPropertyList(plist, format), { charset:"UTF-8" });
}
function addBundleFileSizes(bundlePath, totalBytes)
{
var bundleName = FILE.basename(bundlePath),
environment = bundleName === "Foundation" ? "Objj" : "Browser",
bundlePath = FILE.join(bundlePath, environment + ".environment");
if (FILE.isDirectory(bundlePath))
{
var filename = bundleName + ".sj",
filePath = new FILE.Path(FILE.join(bundlePath, filename));
if (filePath.exists())
totalBytes.executable += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "dataURLs.txt"));
if (filePath.exists())
totalBytes.data += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLData.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLPaths.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7531" systemVersion="14E7f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" promptedForUpgradeToXcode5="NO">
<dependencies>
<deployment version="1090" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="450" id="451"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<view key="contentView" id="372">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="460">
<rect key="frame" x="18" y="177" width="368" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label not translated from xib" id="461">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</window>
<customObject id="450" customClass="AppController">
<connections>
<outlet property="theWindow" destination="371" id="459"/>
</connections>
</customObject>
</objects>
</document>
@@ -0,0 +1,186 @@
/* Class = "NSMenuItem"; title = "Bring All to Front"; ObjectID = "5"; */
"5.title" = "Bring All to Front";
/* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */
"19.title" = "Window";
/* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */
"23.title" = "Minimize";
/* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */
"24.title" = "Window";
/* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */
"29.title" = "AMainMenu";
/* Class = "NSMenuItem"; title = "NewApplication"; ObjectID = "56"; */
"56.title" = "NewApplication";
/* Class = "NSMenu"; title = "NewApplication"; ObjectID = "57"; */
"57.title" = "NewApplication";
/* Class = "NSMenuItem"; title = "About NewApplication"; ObjectID = "58"; */
"58.title" = "About NewApplication";
/* Class = "NSMenuItem"; title = "Open…"; ObjectID = "72"; */
"72.title" = "Open…";
/* Class = "NSMenuItem"; title = "Close"; ObjectID = "73"; */
"73.title" = "Close";
/* Class = "NSMenuItem"; title = "Save"; ObjectID = "75"; */
"75.title" = "Save";
/* Class = "NSMenuItem"; title = "Save As…"; ObjectID = "80"; */
"80.title" = "Save As…";
/* Class = "NSMenu"; title = "File"; ObjectID = "81"; */
"81.title" = "File";
/* Class = "NSMenuItem"; title = "New"; ObjectID = "82"; */
"82.title" = "New";
/* Class = "NSMenuItem"; title = "File"; ObjectID = "83"; */
"83.title" = "File";
/* Class = "NSMenuItem"; title = "Help"; ObjectID = "103"; */
"103.title" = "Help";
/* Class = "NSMenu"; title = "Help"; ObjectID = "106"; */
"106.title" = "Help";
/* Class = "NSMenuItem"; title = "NewApplication Help"; ObjectID = "111"; */
"111.title" = "NewApplication Help";
/* Class = "NSMenuItem"; title = "Revert to Saved"; ObjectID = "112"; */
"112.title" = "Revert to Saved";
/* Class = "NSMenuItem"; title = "Open Recent"; ObjectID = "124"; */
"124.title" = "Open Recent";
/* Class = "NSMenu"; title = "Open Recent"; ObjectID = "125"; */
"125.title" = "Open Recent";
/* Class = "NSMenuItem"; title = "Clear Menu"; ObjectID = "126"; */
"126.title" = "Clear Menu";
/* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */
"129.title" = "Preferences…";
/* Class = "NSMenuItem"; title = "Quit NewApplication"; ObjectID = "136"; */
"136.title" = "Quit NewApplication";
/* Class = "NSMenuItem"; title = "Stop Speaking"; ObjectID = "195"; */
"195.title" = "Stop Speaking";
/* Class = "NSMenuItem"; title = "Start Speaking"; ObjectID = "196"; */
"196.title" = "Start Speaking";
/* Class = "NSMenuItem"; title = "Copy"; ObjectID = "197"; */
"197.title" = "Copy";
/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "198"; */
"198.title" = "Select All";
/* Class = "NSMenuItem"; title = "Cut"; ObjectID = "199"; */
"199.title" = "Cut";
/* Class = "NSMenu"; title = "Spelling and Grammar"; ObjectID = "200"; */
"200.title" = "Spelling and Grammar";
/* Class = "NSMenuItem"; title = "Check Spelling"; ObjectID = "201"; */
"201.title" = "Check Spelling";
/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "202"; */
"202.title" = "Delete";
/* Class = "NSMenuItem"; title = "Paste"; ObjectID = "203"; */
"203.title" = "Paste";
/* Class = "NSMenuItem"; title = "Show Spelling…"; ObjectID = "204"; */
"204.title" = "Show Spelling…";
/* Class = "NSMenu"; title = "Edit"; ObjectID = "205"; */
"205.title" = "Edit";
/* Class = "NSMenuItem"; title = "Undo"; ObjectID = "207"; */
"207.title" = "Undo";
/* Class = "NSMenuItem"; title = "Find Next"; ObjectID = "208"; */
"208.title" = "Find Next";
/* Class = "NSMenuItem"; title = "Find…"; ObjectID = "209"; */
"209.title" = "Find…";
/* Class = "NSMenuItem"; title = "Jump to Selection"; ObjectID = "210"; */
"210.title" = "Jump to Selection";
/* Class = "NSMenuItem"; title = "Speech"; ObjectID = "211"; */
"211.title" = "Speech";
/* Class = "NSMenu"; title = "Speech"; ObjectID = "212"; */
"212.title" = "Speech";
/* Class = "NSMenuItem"; title = "Find Previous"; ObjectID = "213"; */
"213.title" = "Find Previous";
/* Class = "NSMenuItem"; title = "Redo"; ObjectID = "215"; */
"215.title" = "Redo";
/* Class = "NSMenuItem"; title = "Spelling and Grammar"; ObjectID = "216"; */
"216.title" = "Spelling and Grammar";
/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "217"; */
"217.title" = "Edit";
/* Class = "NSMenuItem"; title = "Find"; ObjectID = "218"; */
"218.title" = "Find";
/* Class = "NSMenuItem"; title = "Check Spelling While Typing"; ObjectID = "219"; */
"219.title" = "Check Spelling While Typing";
/* Class = "NSMenu"; title = "Find"; ObjectID = "220"; */
"220.title" = "Find";
/* Class = "NSMenuItem"; title = "Use Selection for Find"; ObjectID = "221"; */
"221.title" = "Use Selection for Find";
/* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */
"239.title" = "Zoom";
/* Class = "NSMenuItem"; title = "View"; ObjectID = "295"; */
"295.title" = "View";
/* Class = "NSMenu"; title = "View"; ObjectID = "296"; */
"296.title" = "View";
/* Class = "NSMenuItem"; title = "Show Toolbar"; ObjectID = "297"; */
"297.title" = "Show Toolbar";
/* Class = "NSMenuItem"; title = "Customize Toolbar…"; ObjectID = "298"; */
"298.title" = "Customize Toolbar…";
/* Class = "NSMenuItem"; title = "Check Grammar With Spelling"; ObjectID = "346"; */
"346.title" = "Check Grammar With Spelling";
/* Class = "NSMenuItem"; title = "Substitutions"; ObjectID = "348"; */
"348.title" = "Substitutions";
/* Class = "NSMenu"; title = "Substitutions"; ObjectID = "349"; */
"349.title" = "Substitutions";
/* Class = "NSMenuItem"; title = "Smart Copy/Paste"; ObjectID = "350"; */
"350.title" = "Smart Copy/Paste";
/* Class = "NSMenuItem"; title = "Smart Quotes"; ObjectID = "351"; */
"351.title" = "Smart Quotes";
/* Class = "NSMenuItem"; title = "Smart Links"; ObjectID = "354"; */
"354.title" = "Smart Links";
/* Class = "NSWindow"; title = "Window"; ObjectID = "371"; */
"371.title" = "Window";
/* Class = "NSTextFieldCell"; title = "Label not translated from xib"; ObjectID = "461"; */
"461.title" = "Label translated from xib in english";
@@ -0,0 +1,2 @@
/* My first context. */
"Label from file" = "Label title from en.lproj from first context from SecondLocalizable";
@@ -0,0 +1,186 @@
/* Class = "NSMenuItem"; title = "Bring All to Front"; ObjectID = "5"; */
"5.title" = "Bring All to Front";
/* Class = "NSMenuItem"; title = "Window"; ObjectID = "19"; */
"19.title" = "Window";
/* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "23"; */
"23.title" = "Minimize";
/* Class = "NSMenu"; title = "Window"; ObjectID = "24"; */
"24.title" = "Window";
/* Class = "NSMenu"; title = "AMainMenu"; ObjectID = "29"; */
"29.title" = "AMainMenu";
/* Class = "NSMenuItem"; title = "NewApplication"; ObjectID = "56"; */
"56.title" = "NewApplication";
/* Class = "NSMenu"; title = "NewApplication"; ObjectID = "57"; */
"57.title" = "NewApplication";
/* Class = "NSMenuItem"; title = "About NewApplication"; ObjectID = "58"; */
"58.title" = "About NewApplication";
/* Class = "NSMenuItem"; title = "Open…"; ObjectID = "72"; */
"72.title" = "Open…";
/* Class = "NSMenuItem"; title = "Close"; ObjectID = "73"; */
"73.title" = "Close";
/* Class = "NSMenuItem"; title = "Save"; ObjectID = "75"; */
"75.title" = "Save";
/* Class = "NSMenuItem"; title = "Save As…"; ObjectID = "80"; */
"80.title" = "Save As…";
/* Class = "NSMenu"; title = "File"; ObjectID = "81"; */
"81.title" = "File";
/* Class = "NSMenuItem"; title = "New"; ObjectID = "82"; */
"82.title" = "New";
/* Class = "NSMenuItem"; title = "File"; ObjectID = "83"; */
"83.title" = "File";
/* Class = "NSMenuItem"; title = "Help"; ObjectID = "103"; */
"103.title" = "Help";
/* Class = "NSMenu"; title = "Help"; ObjectID = "106"; */
"106.title" = "Help";
/* Class = "NSMenuItem"; title = "NewApplication Help"; ObjectID = "111"; */
"111.title" = "NewApplication Help";
/* Class = "NSMenuItem"; title = "Revert to Saved"; ObjectID = "112"; */
"112.title" = "Revert to Saved";
/* Class = "NSMenuItem"; title = "Open Recent"; ObjectID = "124"; */
"124.title" = "Open Recent";
/* Class = "NSMenu"; title = "Open Recent"; ObjectID = "125"; */
"125.title" = "Open Recent";
/* Class = "NSMenuItem"; title = "Clear Menu"; ObjectID = "126"; */
"126.title" = "Clear Menu";
/* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "129"; */
"129.title" = "Preferences…";
/* Class = "NSMenuItem"; title = "Quit NewApplication"; ObjectID = "136"; */
"136.title" = "Quit NewApplication";
/* Class = "NSMenuItem"; title = "Stop Speaking"; ObjectID = "195"; */
"195.title" = "Stop Speaking";
/* Class = "NSMenuItem"; title = "Start Speaking"; ObjectID = "196"; */
"196.title" = "Start Speaking";
/* Class = "NSMenuItem"; title = "Copy"; ObjectID = "197"; */
"197.title" = "Copy";
/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "198"; */
"198.title" = "Select All";
/* Class = "NSMenuItem"; title = "Cut"; ObjectID = "199"; */
"199.title" = "Cut";
/* Class = "NSMenu"; title = "Spelling and Grammar"; ObjectID = "200"; */
"200.title" = "Spelling and Grammar";
/* Class = "NSMenuItem"; title = "Check Spelling"; ObjectID = "201"; */
"201.title" = "Check Spelling";
/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "202"; */
"202.title" = "Delete";
/* Class = "NSMenuItem"; title = "Paste"; ObjectID = "203"; */
"203.title" = "Paste";
/* Class = "NSMenuItem"; title = "Show Spelling…"; ObjectID = "204"; */
"204.title" = "Show Spelling…";
/* Class = "NSMenu"; title = "Edit"; ObjectID = "205"; */
"205.title" = "Edit";
/* Class = "NSMenuItem"; title = "Undo"; ObjectID = "207"; */
"207.title" = "Undo";
/* Class = "NSMenuItem"; title = "Find Next"; ObjectID = "208"; */
"208.title" = "Find Next";
/* Class = "NSMenuItem"; title = "Find…"; ObjectID = "209"; */
"209.title" = "Find…";
/* Class = "NSMenuItem"; title = "Jump to Selection"; ObjectID = "210"; */
"210.title" = "Jump to Selection";
/* Class = "NSMenuItem"; title = "Speech"; ObjectID = "211"; */
"211.title" = "Speech";
/* Class = "NSMenu"; title = "Speech"; ObjectID = "212"; */
"212.title" = "Speech";
/* Class = "NSMenuItem"; title = "Find Previous"; ObjectID = "213"; */
"213.title" = "Find Previous";
/* Class = "NSMenuItem"; title = "Redo"; ObjectID = "215"; */
"215.title" = "Redo";
/* Class = "NSMenuItem"; title = "Spelling and Grammar"; ObjectID = "216"; */
"216.title" = "Spelling and Grammar";
/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "217"; */
"217.title" = "Edit";
/* Class = "NSMenuItem"; title = "Find"; ObjectID = "218"; */
"218.title" = "Find";
/* Class = "NSMenuItem"; title = "Check Spelling While Typing"; ObjectID = "219"; */
"219.title" = "Check Spelling While Typing";
/* Class = "NSMenu"; title = "Find"; ObjectID = "220"; */
"220.title" = "Find";
/* Class = "NSMenuItem"; title = "Use Selection for Find"; ObjectID = "221"; */
"221.title" = "Use Selection for Find";
/* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "239"; */
"239.title" = "Zoom";
/* Class = "NSMenuItem"; title = "View"; ObjectID = "295"; */
"295.title" = "View";
/* Class = "NSMenu"; title = "View"; ObjectID = "296"; */
"296.title" = "View";
/* Class = "NSMenuItem"; title = "Show Toolbar"; ObjectID = "297"; */
"297.title" = "Show Toolbar";
/* Class = "NSMenuItem"; title = "Customize Toolbar…"; ObjectID = "298"; */
"298.title" = "Customize Toolbar…";
/* Class = "NSMenuItem"; title = "Check Grammar With Spelling"; ObjectID = "346"; */
"346.title" = "Check Grammar With Spelling";
/* Class = "NSMenuItem"; title = "Substitutions"; ObjectID = "348"; */
"348.title" = "Substitutions";
/* Class = "NSMenu"; title = "Substitutions"; ObjectID = "349"; */
"349.title" = "Substitutions";
/* Class = "NSMenuItem"; title = "Smart Copy/Paste"; ObjectID = "350"; */
"350.title" = "Smart Copy/Paste";
/* Class = "NSMenuItem"; title = "Smart Quotes"; ObjectID = "351"; */
"351.title" = "Smart Quotes";
/* Class = "NSMenuItem"; title = "Smart Links"; ObjectID = "354"; */
"354.title" = "Smart Links";
/* Class = "NSWindow"; title = "Window"; ObjectID = "371"; */
"371.title" = "Window";
/* Class = "NSTextFieldCell"; title = "Label not translated from xib"; ObjectID = "461"; */
"461.title" = "Label traduit du xib en français";
@@ -0,0 +1,2 @@
/* My first context. */
"Label from file" = "Label traduit de en.lproj du premier context de SecondLocalizable";
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="en">
<!--
index-debug.html
CPLocalizationTest
Created by You on April 20, 2015.
Copyright 2015, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPLocalizationTest</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks"];
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: 0;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
+161
View File
@@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<!--
index.html
CPLocalizationTest
Created by You on April 20, 2015.
Copyright 2015, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPLocalizationTest</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: 0;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPLocalizationTest
*
* Created by You on April 20, 2015.
* Copyright 2015, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
+1
View File
@@ -46,6 +46,7 @@
@import "NSImageView.j"
@import "NSLayoutConstraint.j"
@import "NSLevelIndicator.j"
@import "NSLocalizableString.j"
@import "NSMatrix.j"
@import "NSMenu.j"
@import "NSMenuItem.j"
+60
View File
@@ -0,0 +1,60 @@
/*
* NSLocalizableString.j
* AppKit
*
* Created by Alexandre Wilhelm.
* Copyright 2015, Cappuccino Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <AppKit/_CPLocalizableString.j>
@implementation _CPLocalizableString (CPCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
{
self = [self init];
if (self)
{
_dev = [aCoder decodeObjectForKey:@"NSDev"];
_key = [aCoder decodeObjectForKey:@"NSKey"];
_value = [aCoder decodeObjectForKey:@"NS.string"];
}
return self;
}
@end
@implementation NSLocalizableString : _CPLocalizableString
{
}
- (id)initWithCoder:(CPCoder)aCoder
{
return [self NS_initWithCoder:aCoder];
}
- (Class)classForKeyedArchiver
{
return [_CPLocalizableString class];
}
@end