]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Create .lproj files for each locale.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 29 May 2014 07:54:45 +0000 (15:54 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 29 May 2014 07:54:45 +0000 (15:54 +0800)
atom.gyp
tools/mac/make_locale_dirs.sh [new file with mode: 0755]

index 335b021c4bc8a71438c1c7d8371bbde4991f0b05..ddc2a6b376026f60b1fc296bf98062cd79ffce2b 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
       'atom/app/atom_library_main.cc',
       'atom/app/atom_library_main.h',
     ],
+    'atom_source_root': '<!(python tools/atom_source_root.py)',
     'conditions': [
       ['OS=="win"', {
         'app_sources': [
           '<(libchromiumcontent_src_dir)/content/app/startup_helper_win.cc',
         ],
       }],  # OS=="win"
+      ['OS=="mac"', {
+        'locales': [
+          'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en_GB',
+          'en_US', 'es_419', 'es', 'et', 'fa', 'fi', 'fil', 'fr', 'gu', 'he',
+          'hi', 'hr', 'hu', 'id', 'it', 'ja', 'kn', 'ko', 'lt', 'lv',
+          'ml', 'mr', 'ms', 'nb', 'nl', 'pl', 'pt_BR', 'pt_PT', 'ro', 'ru',
+          'sk', 'sl', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tr', 'uk',
+          'vi', 'zh_CN', 'zh_TW',
+        ],
+      }],  # OS=="mac"
     ],
-    'atom_source_root': '<!(python tools/atom_source_root.py)',
   },
   'target_defaults': {
     'mac_framework_dirs': [
                 '<(product_name)',
               ],
             },
+              # The application doesn't have real localizations, it just has
+              # empty .lproj directories, which is enough to convince Cocoa
+              # atom-shell supports those languages.
+            {
+              'postbuild_name': 'Make Empty Localizations',
+              'action': [
+                'tools/mac/make_locale_dirs.sh',
+                '<@(locales)',
+              ],
+            },
           ]
         }],  # OS=="mac"
         ['OS=="win"', {
diff --git a/tools/mac/make_locale_dirs.sh b/tools/mac/make_locale_dirs.sh
new file mode 100755 (executable)
index 0000000..c479b65
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# usage: make_locale_dirs.sh locale_dir [...]
+#
+# This script creates the Resources directory for the bundle being built by
+# the Xcode target that calls it if the directory does not yet exist. It then
+# changes to that directory and creates subdirectories for each locale_dir
+# passed on the command line.
+#
+# This script is intended to create empty locale directories (.lproj) in a
+# Cocoa .app bundle. The presence of these empty directories is sufficient to
+# convince Cocoa that the application supports the named localization, even if
+# an InfoPlist.strings file is not provided. Chrome uses these empty locale
+# directoires for its helper executable bundles, which do not otherwise
+# require any direct Cocoa locale support.
+
+set -eu
+
+if [[ ${#} -eq 0 ]]; then
+  echo "usage: ${0} locale_dir [...]" >& 2
+  exit 1
+fi
+
+RESOURCES_DIR="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+if [[ ! -d "${RESOURCES_DIR}" ]]; then
+  mkdir "${RESOURCES_DIR}"
+fi
+
+cd "${RESOURCES_DIR}"
+
+for dir in "${@}"; do
+  if [[ ! -d "${dir}.lproj" ]]; then
+    mkdir "${dir}.lproj"
+  fi
+done