1
0
Fork 0
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:
Jakub Vrana 2013-04-23 11:09:23 -07:00
parent b0a6a77edc
commit 6a0ac6b532
3 changed files with 55 additions and 11 deletions

View file

@ -1,8 +1,28 @@
<?php <?php
final class Javelin { final class Javelin {
public static function initBehavior($behavior, array $config = array()) { 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 = CelerityAPI::getStaticResourceResponse();
$response->initBehavior($behavior, $config); $response->initBehavior($behavior, $config);
} }
} }

View 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];
};
};

View file

@ -6,10 +6,13 @@
* javelin-stratcom * javelin-stratcom
* phabricator-dropdown-menu * phabricator-dropdown-menu
* phabricator-menu-item * phabricator-menu-item
* phabricator-phtize
*/ */
JX.behavior('differential-dropdown-menus', function(config) { JX.behavior('differential-dropdown-menus', function(config) {
var pht = JX.phtize(config.pht);
function show_more(container) { function show_more(container) {
var nodes = JX.DOM.scry(container, 'tr', 'context-target'); var nodes = JX.DOM.scry(container, 'tr', 'context-target');
for (var ii = 0; ii < nodes.length; ii++) { for (var ii = 0; ii < nodes.length; ii++) {
@ -46,7 +49,7 @@ JX.behavior('differential-dropdown-menus', function(config) {
if (data.diffusionURI) { if (data.diffusionURI) {
// Show this only if we have a link, since when this appears in Diffusion // Show this only if we have a link, since when this appears in Diffusion
// it is otherwise potentially confusing. // 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]) var menu = new JX.PhabricatorDropdownMenu(buttons[ii])
@ -63,25 +66,25 @@ JX.behavior('differential-dropdown-menus', function(config) {
menu.addItem(diffusion_item); menu.addItem(diffusion_item);
} }
menu.addItem(link_to('View Standalone', data.standaloneURI)); menu.addItem(link_to(pht('View Standalone'), data.standaloneURI));
if (data.leftURI) { 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) { 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) { if (data.editor) {
menu.addItem(new JX.PhabricatorMenuItem( menu.addItem(new JX.PhabricatorMenuItem(
'Open in Editor', pht('Open in Editor'),
JX.bind(null, location.assign, data.editor), // Open in the same window. JX.bind(null, location.assign, data.editor), // Open in the same window.
data.editor)); data.editor));
} }
if (data.editorConfigure) { if (data.editorConfigure) {
menu.addItem(link_to('Configure Editor', data.editorConfigure)); menu.addItem(link_to(pht('Configure Editor'), data.editorConfigure));
} }
menu.listen( menu.listen(
@ -95,14 +98,14 @@ JX.behavior('differential-dropdown-menus', function(config) {
var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more'); var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more');
if (nodes.length) { if (nodes.length) {
reveal_item.setDisabled(false); reveal_item.setDisabled(false);
reveal_item.setName('Show Entire File'); reveal_item.setName(pht('Show Entire File'));
} else { } else {
reveal_item.setDisabled(true); reveal_item.setDisabled(true);
reveal_item.setName('Entire File Shown'); reveal_item.setName(pht('Entire File Shown'));
} }
visible_item.setDisabled(true); 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), var diffs = JX.DOM.scry(JX.$(data.containerID),
'table', 'differential-diff'); 'table', 'differential-diff');
if (diffs.length > 1) { if (diffs.length > 1) {
@ -113,9 +116,9 @@ JX.behavior('differential-dropdown-menus', function(config) {
diff = diffs[0]; diff = diffs[0];
visible_item.setDisabled(false); visible_item.setDisabled(false);
if (JX.Stratcom.getData(diff).hidden) { if (JX.Stratcom.getData(diff).hidden) {
visible_item.setName('Expand File'); visible_item.setName(pht('Expand File'));
} else { } else {
visible_item.setName('Collapse File'); visible_item.setName(pht('Collapse File'));
} }
} else { } else {
// Do nothing when there is no diff shown in the table. For example, // Do nothing when there is no diff shown in the table. For example,