mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
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
This commit is contained in:
parent
b0a6a77edc
commit
6a0ac6b532
3 changed files with 55 additions and 11 deletions
|
@ -1,8 +1,28 @@
|
|||
<?php
|
||||
|
||||
final class Javelin {
|
||||
|
||||
public static function initBehavior($behavior, array $config = array()) {
|
||||
switch ($behavior) {
|
||||
case 'differential-dropdown-menus':
|
||||
$config['pht'] = array(
|
||||
'Open in Editor' => 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
21
webroot/rsrc/js/application/core/phtize.js
Normal file
21
webroot/rsrc/js/application/core/phtize.js
Normal file
|
@ -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];
|
||||
};
|
||||
|
||||
};
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue