Browse Source

mac: Create .lproj files for each locale.

Cheng Zhao 11 years ago
parent
commit
7bd0c8aa06
2 changed files with 60 additions and 1 deletions
  1. 21 1
      atom.gyp
  2. 39 0
      tools/mac/make_locale_dirs.sh

+ 21 - 1
atom.gyp

@@ -221,6 +221,7 @@
       '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': [
@@ -230,8 +231,17 @@
           '<(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': [
@@ -317,6 +327,16 @@
                 '<(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"', {

+ 39 - 0
tools/mac/make_locale_dirs.sh

@@ -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