Skip to content

Commit

Permalink
Bug 1232241 - Move Firefox for iOS strings from SVN to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo committed Dec 15, 2015
1 parent 7f952f3 commit 11e7c83
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 106 deletions.
2 changes: 1 addition & 1 deletion app/classes/Transvision/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static function getLocaleInContext($locale, $context)
$context = 'gaia';
}

// Firefox for iOS: no mapping
// Firefox for iOS
$locale_mappings['firefox_ios'] = [
'es-AR' => 'es',
'es-ES' => 'es',
Expand Down
33 changes: 10 additions & 23 deletions app/classes/Transvision/ShowResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,12 @@ public static function resultsTable($search_id, $search_results, $recherche, $lo
$temp = explode('-', $locale2);
$locale2_short_code = $temp[0];

switch ($current_repo) {
case 'mozilla_org':
$locale1_path = VersionControl::gitPath($locale1, $current_repo, $key);
$locale2_path = VersionControl::gitPath($locale2, $current_repo, $key);
break;
case 'firefox_ios':
$locale1_path = VersionControl::svnPath($locale1, $current_repo, $key);
$locale2_path = VersionControl::svnPath($locale2, $current_repo, $key);
break;
default:
$locale1_path = VersionControl::hgPath($locale1, $current_repo, $key);
$locale2_path = VersionControl::hgPath($locale2, $current_repo, $key);
break;
if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) {
$locale1_path = VersionControl::gitPath($locale1, $current_repo, $key);
$locale2_path = VersionControl::gitPath($locale2, $current_repo, $key);
} else {
$locale1_path = VersionControl::hgPath($locale1, $current_repo, $key);
$locale2_path = VersionControl::hgPath($locale2, $current_repo, $key);
}

// errors
Expand Down Expand Up @@ -346,16 +339,10 @@ public static function resultsTable($search_id, $search_results, $recherche, $lo

// 3locales view
if (isset($search_options["extra_locale"])) {
switch ($current_repo) {
case 'mozilla_org':
$locale3_path = VersionControl::gitPath($locale3, $current_repo, $key);
break;
case 'firefox_ios':
$locale3_path = VersionControl::svnPath($locale3, $current_repo, $key);
break;
default:
$locale3_path = VersionControl::hgPath($locale3, $current_repo, $key);
break;
if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) {
$locale3_path = VersionControl::gitPath($locale3, $current_repo, $key);
} else {
$locale3_path = VersionControl::hgPath($locale3, $current_repo, $key);
}

$clipboard_target_string2 = 'clip_' . md5($target_string2);
Expand Down
37 changes: 11 additions & 26 deletions app/classes/Transvision/VersionControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class VersionControl
public static function getVCS($repo)
{
$vcs = [
'git' => ['mozilla_org'],
'git' => ['firefox_ios', 'mozilla_org'],
'hg' => [],
'svn' => ['firefox_ios'],
'svn' => [],
];
$vcs['hg'] = array_merge(
Project::getDesktopRepositories(),
Expand Down Expand Up @@ -187,26 +187,6 @@ public static function hgPath($locale, $repo, $path)
return $url . $path . '/' . $entity_file;
}

/**
* Generate a path to the subversion repo for the file
*
* @param string $locale locale code
* @param string $repo repository name
* @param string $path Entity name representing the local file
* @return string Path to the file in remote subversion repository
*/
public static function svnPath($locale, $repo, $path)
{
if ($repo == 'firefox_ios') {
$file_path = "projects/l10n-misc/trunk/firefox-ios/{$locale}/firefox-ios.xliff";
} else {
$file_path = '';
}

return 'https://viewvc.svn.mozilla.org/vc/'
. $file_path . '?view=markup';
}

/**
* Generate a path to the GitHub repo for the file.
* Only mozilla.org is supported for now.
Expand All @@ -219,15 +199,20 @@ public static function svnPath($locale, $repo, $path)
public static function gitPath($locale, $repo, $path)
{
switch ($repo) {
case 'firefox_ios':
$repo = 'firefoxios-l10n';
$file_path = 'firefox-ios.xliff';
break;
case 'mozilla_org':
default:
$repo = 'www.mozilla.org';
$file_path = self::extractFilePath($path);
break;
default:
$file_path = $path;
break;
}

return 'https://github.com/mozilla-l10n/'
. $repo . '/blob/master/'
. $locale . '/' . self::extractFilePath($path);
return "https://github.com/mozilla-l10n/{$repo}/blob/master/{$locale}/$file_path";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/bash_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mozilla_org=$local_git/mozilla_org/
folders+=( $mozilla_org )

# Firefox for iOS (XLIFF)
firefox_ios=$local_svn/firefox_ios/
firefox_ios=$local_git/firefox_ios/
folders+=( $firefox_ios )

# l20n test repo
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/glossaire.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ function updateFirefoxiOS() {
if $checkrepo
then
cd $firefox_ios
echogreen "Update subversion repository"
svn up
echogreen "Update GitHub repository"
git pull
fi
if $createTMX
then
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ then
git clone https://github.com/mozilla-l10n/www.mozilla.org .
fi

echogreen "Firefox for iOS repo being checked out from subversion"
echogreen "Firefox for iOS repo being checked out from GitHub"
cd $firefox_ios
if [ ! -d $firefox_ios/.svn ]
if [ ! -d $firefox_ios/.git ]
then
echogreen "Checking out Firefox for iOS repo"
svn co https://svn.mozilla.org/projects/l10n-misc/trunk/firefox-ios/ .
git clone https://github.com/mozilla-l10n/firefoxios-l10n .
fi

# We now deal with L20n test repo as a specific case
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/tmx_xliff
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $project_name = $argv[1];
$supported_projects = [
'firefox_ios' => [
'file_name' => 'firefox-ios.xliff',
'base_path' => SVN . 'firefox_ios',
'base_path' => GIT . 'firefox_ios',
],
];

Expand Down
33 changes: 10 additions & 23 deletions app/views/results_entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@
$current_repo = $check['repo'];
// Display results
foreach ($entities as $entity) {
switch ($current_repo) {
case 'mozilla_org':
$path_locale1 = VersionControl::gitPath($source_locale, $current_repo, $entity);
$path_locale2 = VersionControl::gitPath($locale, $current_repo, $entity);
break;
case 'firefox_ios':
$path_locale1 = VersionControl::svnPath($source_locale, $current_repo, $entity);
$path_locale2 = VersionControl::svnPath($locale, $current_repo, $entity);
break;
default:
$path_locale1 = VersionControl::hgPath($source_locale, $current_repo, $entity);
$path_locale2 = VersionControl::hgPath($locale, $current_repo, $entity);
break;
if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) {
$path_locale1 = VersionControl::gitPath($source_locale, $current_repo, $entity);
$path_locale2 = VersionControl::gitPath($locale, $current_repo, $entity);
} else {
$path_locale1 = VersionControl::hgPath($source_locale, $current_repo, $entity);
$path_locale2 = VersionControl::hgPath($locale, $current_repo, $entity);
}

// Escape strings for HTML display
Expand All @@ -48,16 +41,10 @@
// Highlight non-breaking spaces only after strings have been escaped
$target_string2 = str_replace(' ', '<span class="highlight-gray"> </span>', $target_string2);

switch ($current_repo) {
case 'mozilla_org':
$path_locale3 = VersionControl::gitPath($locale2, $current_repo, $entity);
break;
case 'firefox_ios':
$path_locale3 = VersionControl::svnPath($locale2, $current_repo, $entity);
break;
default:
$path_locale3 = VersionControl::hgPath($locale2, $current_repo, $entity);
break;
if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) {
$path_locale3 = VersionControl::gitPath($locale2, $current_repo, $entity);
} else {
$path_locale3 = VersionControl::hgPath($locale2, $current_repo, $entity);
}

// Link to entity
Expand Down
35 changes: 9 additions & 26 deletions tests/units/Transvision/VersionControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getVCSDP()
'central', 'hg',
],
[
'firefox_ios', 'svn',
'firefox_ios', 'git',
],
];
}
Expand Down Expand Up @@ -131,38 +131,15 @@ public function testHgFile($a, $b, $c, $d)
->isEqualTo($d);
}

public function svnFileDP()
public function gitFileDP()
{
return [
[
'es-ES',
'random_repo',
'mozilla_org/firefox/os/faq.lang:c71a7a50',
'https://viewvc.svn.mozilla.org/vc/?view=markup',
],
[
'it',
'firefox_ios',
'firefox_ios/Client/ClearPrivateData.strings:0f4d892c',
'https://viewvc.svn.mozilla.org/vc/projects/l10n-misc/trunk/firefox-ios/it/firefox-ios.xliff?view=markup',
'https://github.com/mozilla-l10n/firefoxios-l10n/blob/master/it/firefox-ios.xliff',
],
];
}

/**
* @dataProvider svnFileDP
*/
public function testSvnFile($a, $b, $c, $d)
{
$obj = new _VersionControl();
$this
->string($obj->svnPath($a, $b, $c))
->isEqualTo($d);
}

public function gitFileDP()
{
return [
[
'sr',
'mozilla_org',
Expand All @@ -175,6 +152,12 @@ public function gitFileDP()
'mozilla_org/firefox/os/faq.lang:c71a7a50',
'https://github.com/mozilla-l10n/www.mozilla.org/blob/master/es-ES/firefox/os/faq.lang',
],
[
'fr',
'unknown',
'test/file.properties',
'https://github.com/mozilla-l10n/unknown/blob/master/fr/test/file.properties',
],
];
}

Expand Down

0 comments on commit 11e7c83

Please sign in to comment.