Skip to content

Commit ae5052a

Browse files
committed
Mac i18n: locale packaging and integration
Using user default locale in node-webkit
1 parent d55a9a5 commit ae5052a

File tree

8 files changed

+100
-5071
lines changed

8 files changed

+100
-5071
lines changed

nw.gypi

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,13 @@
459459
},
460460
'includes': [ '../../build/grit_action.gypi' ],
461461
},
462+
{
463+
'action_name': 'nw_strings',
464+
'variables': {
465+
'grit_grd_file': 'src/resources/nw_strings.grd',
466+
},
467+
'includes': [ '../../build/grit_action.gypi' ],
468+
},
462469
],
463470
},
464471
{
@@ -507,13 +514,13 @@
507514
'variables': {
508515
'pak_inputs': [
509516
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
510-
'<(SHARED_INTERMEDIATE_DIR)/content/nw_resources_zh-CN.pak',
517+
'<(SHARED_INTERMEDIATE_DIR)/content/nw_resources.pak',
511518
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
512519
'<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings/app_locale_settings_en-US.pak',
513520
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak',
514521
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings/ui_strings_en-US.pak',
515522
'<(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak',
516-
#'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak',
523+
'<(SHARED_INTERMEDIATE_DIR)/webkit/blink_resources.pak',
517524
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources_100_percent.pak',
518525
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak',
519526
],
@@ -731,7 +738,60 @@
731738
'mac_bundle': 1,
732739
'mac_bundle_resources': [
733740
'src/mac/English.lproj/HttpAuth.xib',
734-
'<(PRODUCT_DIR)/nw.pak'
741+
'<(PRODUCT_DIR)/nw.pak',
742+
'<(PRODUCT_DIR)/locale/en-US.pak',
743+
'<(PRODUCT_DIR)/locale/am.pak',
744+
'<(PRODUCT_DIR)/locale/ar.pak',
745+
'<(PRODUCT_DIR)/locale/bg.pak',
746+
'<(PRODUCT_DIR)/locale/bn.pak',
747+
'<(PRODUCT_DIR)/locale/ca.pak',
748+
'<(PRODUCT_DIR)/locale/cs.pak',
749+
'<(PRODUCT_DIR)/locale/da.pak',
750+
'<(PRODUCT_DIR)/locale/de.pak',
751+
'<(PRODUCT_DIR)/locale/el.pak',
752+
'<(PRODUCT_DIR)/locale/en-GB.pak',
753+
'<(PRODUCT_DIR)/locale/es.pak',
754+
'<(PRODUCT_DIR)/locale/es-419.pak',
755+
'<(PRODUCT_DIR)/locale/et.pak',
756+
'<(PRODUCT_DIR)/locale/fa.pak',
757+
'<(PRODUCT_DIR)/locale/fi.pak',
758+
'<(PRODUCT_DIR)/locale/fil.pak',
759+
'<(PRODUCT_DIR)/locale/fr.pak',
760+
'<(PRODUCT_DIR)/locale/gu.pak',
761+
'<(PRODUCT_DIR)/locale/hi.pak',
762+
'<(PRODUCT_DIR)/locale/hr.pak',
763+
'<(PRODUCT_DIR)/locale/hu.pak',
764+
'<(PRODUCT_DIR)/locale/id.pak',
765+
'<(PRODUCT_DIR)/locale/it.pak',
766+
'<(PRODUCT_DIR)/locale/iw.pak',
767+
'<(PRODUCT_DIR)/locale/ja.pak',
768+
'<(PRODUCT_DIR)/locale/kn.pak',
769+
'<(PRODUCT_DIR)/locale/ko.pak',
770+
'<(PRODUCT_DIR)/locale/lt.pak',
771+
'<(PRODUCT_DIR)/locale/lv.pak',
772+
'<(PRODUCT_DIR)/locale/ml.pak',
773+
'<(PRODUCT_DIR)/locale/mr.pak',
774+
'<(PRODUCT_DIR)/locale/ms.pak',
775+
'<(PRODUCT_DIR)/locale/nl.pak',
776+
'<(PRODUCT_DIR)/locale/no.pak',
777+
'<(PRODUCT_DIR)/locale/pl.pak',
778+
'<(PRODUCT_DIR)/locale/pt-BR.pak',
779+
'<(PRODUCT_DIR)/locale/pt-PT.pak',
780+
'<(PRODUCT_DIR)/locale/ro.pak',
781+
'<(PRODUCT_DIR)/locale/ru.pak',
782+
'<(PRODUCT_DIR)/locale/sk.pak',
783+
'<(PRODUCT_DIR)/locale/sl.pak',
784+
'<(PRODUCT_DIR)/locale/sr.pak',
785+
'<(PRODUCT_DIR)/locale/sv.pak',
786+
'<(PRODUCT_DIR)/locale/sw.pak',
787+
'<(PRODUCT_DIR)/locale/ta.pak',
788+
'<(PRODUCT_DIR)/locale/te.pak',
789+
'<(PRODUCT_DIR)/locale/th.pak',
790+
'<(PRODUCT_DIR)/locale/tr.pak',
791+
'<(PRODUCT_DIR)/locale/uk.pak',
792+
'<(PRODUCT_DIR)/locale/vi.pak',
793+
'<(PRODUCT_DIR)/locale/zh-CN.pak',
794+
'<(PRODUCT_DIR)/locale/zh-TW.pak',
735795
],
736796
'dependencies': [
737797
'nw_lib',

src/browser/standard_menus_mac.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "base/strings/sys_string_conversions.h"
2424
#include "base/strings/utf_string_conversions.h"
25-
#include "grit/nw_resources.h"
25+
#include "grit/nw_strings.h"
2626
#include "ui/base/l10n/l10n_util.h"
2727
#include "ui/base/l10n/l10n_util_mac.h"
2828

src/paths_mac.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ void OverrideFrameworkBundlePath();
1414
void OverrideChildProcessPath();
1515

1616
// Gets the path to the content shell's pak file.
17-
base::FilePath GetResourcesPakFilePath();
17+
bool GetResourcesPakFilePath(base::FilePath& output);
1818

19+
bool GetLocalePakFilePath(const std::string& locale, base::FilePath& output);
1920
base::FilePath GetFrameworksPath();
2021

2122
#endif // CONTENT_SHELL_PATHS_MAC_H_

src/paths_mac.mm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "base/mac/bundle_locations.h"
2424
#include "base/mac/foundation_util.h"
2525
#include "base/path_service.h"
26+
#include "base/strings/sys_string_conversions.h"
2627
#include "content/public/common/content_paths.h"
2728

2829
using base::FilePath;
@@ -64,10 +65,24 @@ void OverrideChildProcessPath() {
6465
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
6566
}
6667

67-
FilePath GetResourcesPakFilePath() {
68+
bool GetResourcesPakFilePath(FilePath& output) {
6869
NSString* pak_path =
6970
[base::mac::FrameworkBundle() pathForResource:@"nw"
7071
ofType:@"pak"];
7172

72-
return FilePath([pak_path fileSystemRepresentation]);
73+
if (!pak_path)
74+
return false;
75+
output = FilePath([pak_path fileSystemRepresentation]);
76+
return true;
77+
}
78+
79+
bool GetLocalePakFilePath(const std::string& locale, FilePath& output) {
80+
NSString* pak_path =
81+
[base::mac::FrameworkBundle() pathForResource:base::SysUTF8ToNSString(locale)
82+
ofType:@"pak"];
83+
84+
if (!pak_path)
85+
return false;
86+
output = FilePath([pak_path fileSystemRepresentation]);
87+
return true;
7388
}

src/resources/nw_resources.grd

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,7 @@
77
<output filename="grit/nw_resources_map.cc" type="resource_map_source" context="default_100_percent"/>
88
<output filename="grit/nw_resources_map.h" type="resource_map_header" context="default_100_percent"/>
99
<output filename="nw_resources.pak" type="data_package" context="default_100_percent"/>
10-
<!--
11-
<output filename="nw_resources_de.pak" type="data_package" lang="de" />
12-
<output filename="nw_resources_es.pak" type="data_package" lang="es" />
13-
<output filename="nw_resources_fr.pak" type="data_package" lang="fr" />
14-
<output filename="nw_resources_jp.pak" type="data_package" lang="jp" />
15-
<output filename="nw_resources_pt-BR.pak" type="data_package" lang="pt-BR" />
16-
-->
17-
<output filename="nw_resources_zh-CN.pak" type="data_package" lang="zh-CN" context="default_100_percent"/>
1810
</outputs>
19-
<translations>
20-
<!--
21-
<file path="nw_resources_de.xtb" lang="de" />
22-
<file path="nw_resources_es.xtb" lang="es" />
23-
<file path="nw_resources_fr.xtb" lang="fr" />
24-
<file path="nw_resources_jp.xtb" lang="jp" />
25-
<file path="nw_resources_pt-BR.xtb" lang="pt-BR" />
26-
-->
27-
<file path="nw_resources_zh-CN.xtb" lang="zh-CN" />
28-
</translations>
2911
<release seq="1">
3012
<structures fallback_to_low_resolution="true">
3113
<structure type="chrome_scaled_image" name="IDR_NW_DEFAULT_ICON" file="nw.png" />
@@ -100,61 +82,6 @@
10082
<message name="IDS_CUSTOM_FILES" desc="The description of the custom file extensions in the select file dialog.">
10183
Custom Files
10284
</message>
103-
<if expr="is_macosx">
104-
<message name="IDS_EDIT_MENU_MAC" desc="The menu title of the Mac edit menu.">
105-
Edit
106-
</message>
107-
<message name="IDS_WINDOW_MENU_MAC" desc="The menu title of the Mac window menu.">
108-
Window
109-
</message>
110-
<message name="IDS_ABOUT_MAC" desc="The Mac menu item to open the about box.">
111-
About <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>
112-
</message>
113-
<message name="IDS_HIDE_APP_MAC" desc="The Mac menu item to hide all browser windows in the app menu.">
114-
Hide <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>
115-
</message>
116-
<message name="IDS_HIDE_OTHERS_MAC" desc="The Mac menu item to hide other applications' windows in the app menu.">
117-
Hide Others
118-
</message>
119-
<message name="IDS_SHOW_ALL_MAC" desc="The Mac menu item to show all browser windows in the app menu.">
120-
Show All
121-
</message>
122-
<message name="IDS_EXIT_MAC" desc="The Mac menu item to quit the browser in the app menu.">
123-
Quit <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>
124-
</message>
125-
<message name="IDS_EDIT_UNDO_MAC" desc="The Mac menu item undo in the edit menu.">
126-
Undo
127-
</message>
128-
<message name="IDS_EDIT_REDO_MAC" desc="The Mac menu item redo in the edit menu.">
129-
Redo
130-
</message>
131-
<message name="IDS_CUT_MAC" desc="The Mac menu item for cut in the edit menu.">
132-
Cut
133-
</message>
134-
<message name="IDS_COPY_MAC" desc="The Mac menu item for copy in the edit menu.">
135-
Copy
136-
</message>
137-
<message name="IDS_PASTE_MAC" desc="The Mac menu item for paste in the edit menu.">
138-
Paste
139-
</message>
140-
<message name="IDS_EDIT_DELETE_MAC" desc="The Mac menu item delete in the edit menu.">
141-
Delete
142-
</message>
143-
<message name="IDS_EDIT_SELECT_ALL_MAC" desc="The Mac menu item select all in the edit menu.">
144-
Select All
145-
</message>
146-
<message name="IDS_MINIMIZE_WINDOW_MAC"
147-
desc="The Mac menu item for minimize the window menu."
148-
meaning="Mac Menubar: The Mac menu item for minimize the window menu.">
149-
Minimize
150-
</message>
151-
<message name="IDS_CLOSE_WINDOW_MAC" desc="The Mac menu item to close a window in the file menu.">
152-
Close Window
153-
</message>
154-
<message name="IDS_ALL_WINDOWS_FRONT_MAC" desc="The Mac menu item for bring all to front the window menu.">
155-
Bring All to Front
156-
</message>
157-
</if>
15885
</messages>
15986
</release>
16087
</grit>

0 commit comments

Comments
 (0)