Merge pull request #4027 from atom/fix-locale

Fix loading locale on OS X
This commit is contained in:
Cheng Zhao 2016-01-08 13:32:53 +08:00
Родитель 5f6a8a7c24 5514e89276
Коммит 9a707b7c69
6 изменённых файлов: 71 добавлений и 25 удалений

Просмотреть файл

@ -432,7 +432,6 @@
'mac_bundle': 1,
'mac_bundle_resources': [
'atom/common/resources/mac/MainMenu.xib',
'<(libchromiumcontent_dir)/locales',
'<(libchromiumcontent_dir)/content_shell.pak',
'<(libchromiumcontent_dir)/icudtl.dat',
'<(libchromiumcontent_dir)/natives_blob.bin',
@ -501,6 +500,16 @@
'Libraries',
],
},
{
'postbuild_name': 'Copy locales',
'action': [
'tools/mac/copy-locales.py',
'-d',
'<(libchromiumcontent_dir)/locales',
'${BUILT_PRODUCTS_DIR}/<(product_name) Framework.framework/Resources',
'<@(locales)',
],
},
],
'conditions': [
['mas_build==0', {

Просмотреть файл

@ -18,6 +18,7 @@
#include "base/logging.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/common/content_switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace atom {
@ -137,16 +138,4 @@ scoped_ptr<brightray::ContentClient> AtomMainDelegate::CreateContentClient() {
return scoped_ptr<brightray::ContentClient>(new AtomContentClient).Pass();
}
void AtomMainDelegate::AddDataPackFromPath(
ui::ResourceBundle* bundle, const base::FilePath& pak_dir) {
#if defined(OS_WIN)
bundle->AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("ui_resources_200_percent.pak")),
ui::SCALE_FACTOR_200P);
bundle->AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("content_resources_200_percent.pak")),
ui::SCALE_FACTOR_200P);
#endif
}
} // namespace atom

Просмотреть файл

@ -25,8 +25,6 @@ class AtomMainDelegate : public brightray::MainDelegate {
// brightray::MainDelegate:
scoped_ptr<brightray::ContentClient> CreateContentClient() override;
void AddDataPackFromPath(
ui::ResourceBundle* bundle, const base::FilePath& pak_dir) override;
#if defined(OS_MACOSX)
void OverrideChildProcessPath() override;
void OverrideFrameworkBundlePath() override;

Просмотреть файл

@ -13,20 +13,14 @@
namespace atom {
void AtomBrowserMainParts::PreMainMessageLoopStart() {
// Initialize locale setting.
l10n_util::OverrideLocaleWithCocoaLocale();
// Force the NSApplication subclass to be used.
NSApplication* application = [AtomApplication sharedApplication];
[AtomApplication sharedApplication];
// Set our own application delegate.
AtomApplicationDelegate* delegate = [[AtomApplicationDelegate alloc] init];
[NSApp setDelegate:(id<NSFileManagerDelegate>)delegate];
NSBundle* frameworkBundle = base::mac::FrameworkBundle();
NSNib* mainNib = [[NSNib alloc] initWithNibNamed:@"MainMenu"
bundle:frameworkBundle];
[mainNib instantiateWithOwner:application topLevelObjects:nil];
[mainNib release];
brightray::BrowserMainParts::PreMainMessageLoopStart();
// Prevent Cocoa from turning command-line arguments into
// |-application:openFiles:|, since we already handle them directly.

56
tools/mac/copy-locales.py Executable file
Просмотреть файл

@ -0,0 +1,56 @@
#!/usr/bin/env python
# Copyright (c) 2013 GitHub, Inc.
# Use of this source code is governed by the MIT license that can be
# found in the LICENSE file.
import errno
import optparse
import os
import shutil
import sys
def main(argv):
parser = optparse.OptionParser()
usage = 'usage: %s [options ...] src dest locale_list'
parser.set_usage(usage.replace('%s', '%prog'))
parser.add_option('-d', dest='dash_to_underscore', action="store_true",
default=False,
help='map "en-US" to "en" and "-" to "_" in locales')
(options, arglist) = parser.parse_args(argv)
if len(arglist) < 4:
print 'ERROR: need src, dest and list of locales'
return 1
src = arglist[1]
dest = arglist[2]
locales = arglist[3:]
for locale in locales:
# For Cocoa to find the locale at runtime, it needs to use '_' instead
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
dirname = locale
if options.dash_to_underscore:
if locale == 'en-US':
dirname = 'en'
else:
dirname = locale.replace('-', '_')
dirname = os.path.join(dest, dirname + '.lproj')
safe_mkdir(dirname)
shutil.copy2(os.path.join(src, locale + '.pak'),
os.path.join(dirname, 'locale.pak'))
def safe_mkdir(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
if __name__ == '__main__':
sys.exit(main(sys.argv))

2
vendor/brightray поставляемый

@ -1 +1 @@
Subproject commit f9c272ec86ee83915729cf2ecdfdd5aa418b77eb
Subproject commit 8550f2a032b332d86bd8a7ec235685e22d028906