From 6a0ac6b5324e34d932a1bb760f60049257f6f31f Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 23 Apr 2013 11:09:23 -0700 Subject: [PATCH] Translate differential-dropdown-menus Summary: This is a simpler version of D5649. Test Plan: Switched to ALL CAPS translation and clicked View Options. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1139 Differential Revision: https://secure.phabricator.com/D5759 --- src/infrastructure/javelin/Javelin.php | 20 +++++++++++++++ webroot/rsrc/js/application/core/phtize.js | 21 ++++++++++++++++ .../differential/behavior-dropdown-menus.js | 25 +++++++++++-------- 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 webroot/rsrc/js/application/core/phtize.js diff --git a/src/infrastructure/javelin/Javelin.php b/src/infrastructure/javelin/Javelin.php index 04e90b0b5e..5d4ab3b812 100644 --- a/src/infrastructure/javelin/Javelin.php +++ b/src/infrastructure/javelin/Javelin.php @@ -1,8 +1,28 @@ pht('Open in Editor'), + 'Show Entire File' => pht('Show Entire File'), + 'Entire File Shown' => pht('Entire File Shown'), + "Can't Toggle Unloaded File" => pht("Can't Toggle Unloaded File"), + 'Expand File' => pht('Expand File'), + 'Collapse File' => pht('Collapse File'), + 'Browse in Diffusion' => pht('Browse in Diffusion'), + 'View Standalone' => pht('View Standalone'), + 'Show Raw File (Left)' => pht('Show Raw File (Left)'), + 'Show Raw File (Right)' => pht('Show Raw File (Right)'), + 'Configure Editor' => pht('Configure Editor'), + ); + break; + } + $response = CelerityAPI::getStaticResourceResponse(); $response->initBehavior($behavior, $config); } + } diff --git a/webroot/rsrc/js/application/core/phtize.js b/webroot/rsrc/js/application/core/phtize.js new file mode 100644 index 0000000000..a48970c411 --- /dev/null +++ b/webroot/rsrc/js/application/core/phtize.js @@ -0,0 +1,21 @@ +/** + * @provides phabricator-phtize + * @requires javelin-util + * @javelin + */ + +JX.phtize = function(config) { + + return function(text) { + if (!(text in config)) { + if (__DEV__) { + JX.$E('pht("' + text + '"): translation was not configured.'); + } + + return text; + } + + return config[text]; + }; + +}; diff --git a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js index a49293f343..e199bca5fa 100644 --- a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js +++ b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js @@ -6,10 +6,13 @@ * javelin-stratcom * phabricator-dropdown-menu * phabricator-menu-item + * phabricator-phtize */ JX.behavior('differential-dropdown-menus', function(config) { + var pht = JX.phtize(config.pht); + function show_more(container) { var nodes = JX.DOM.scry(container, 'tr', 'context-target'); for (var ii = 0; ii < nodes.length; ii++) { @@ -46,7 +49,7 @@ JX.behavior('differential-dropdown-menus', function(config) { if (data.diffusionURI) { // Show this only if we have a link, since when this appears in Diffusion // it is otherwise potentially confusing. - diffusion_item = link_to('Browse in Diffusion', data.diffusionURI); + diffusion_item = link_to(pht('Browse in Diffusion'), data.diffusionURI); } var menu = new JX.PhabricatorDropdownMenu(buttons[ii]) @@ -63,25 +66,25 @@ JX.behavior('differential-dropdown-menus', function(config) { menu.addItem(diffusion_item); } - menu.addItem(link_to('View Standalone', data.standaloneURI)); + menu.addItem(link_to(pht('View Standalone'), data.standaloneURI)); if (data.leftURI) { - menu.addItem(link_to('Show Raw File (Left)', data.leftURI)); + menu.addItem(link_to(pht('Show Raw File (Left)'), data.leftURI)); } if (data.rightURI) { - menu.addItem(link_to('Show Raw File (Right)', data.rightURI)); + menu.addItem(link_to(pht('Show Raw File (Right)'), data.rightURI)); } if (data.editor) { menu.addItem(new JX.PhabricatorMenuItem( - 'Open in Editor', + pht('Open in Editor'), JX.bind(null, location.assign, data.editor), // Open in the same window. data.editor)); } if (data.editorConfigure) { - menu.addItem(link_to('Configure Editor', data.editorConfigure)); + menu.addItem(link_to(pht('Configure Editor'), data.editorConfigure)); } menu.listen( @@ -95,14 +98,14 @@ JX.behavior('differential-dropdown-menus', function(config) { var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more'); if (nodes.length) { reveal_item.setDisabled(false); - reveal_item.setName('Show Entire File'); + reveal_item.setName(pht('Show Entire File')); } else { reveal_item.setDisabled(true); - reveal_item.setName('Entire File Shown'); + reveal_item.setName(pht('Entire File Shown')); } visible_item.setDisabled(true); - visible_item.setName("Can't Toggle Unloaded File"); + visible_item.setName(pht("Can't Toggle Unloaded File")); var diffs = JX.DOM.scry(JX.$(data.containerID), 'table', 'differential-diff'); if (diffs.length > 1) { @@ -113,9 +116,9 @@ JX.behavior('differential-dropdown-menus', function(config) { diff = diffs[0]; visible_item.setDisabled(false); if (JX.Stratcom.getData(diff).hidden) { - visible_item.setName('Expand File'); + visible_item.setName(pht('Expand File')); } else { - visible_item.setName('Collapse File'); + visible_item.setName(pht('Collapse File')); } } else { // Do nothing when there is no diff shown in the table. For example,