Skip to content

Commit

Permalink
Switch Thunderbird and Seamonkey to Git (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo authored Aug 15, 2024
1 parent 8a889bf commit c81e9af
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 95 deletions.
27 changes: 17 additions & 10 deletions app/classes/Transvision/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Project
*
* files: list of files to analyze during extraction
*
* git_repository: name of remote Git repository in the mozilla-l10n org
* git_repository: name of remote Git repository
*
* git_subfolder: if localizations are in a subdirectory, e.g. if they're
* subfolders in /locales, value will be simply "locales" (no ending or
Expand Down Expand Up @@ -48,7 +48,7 @@ class Project
'meta' => true,
],
'firefox_ios' => [
'git_repository' => 'firefoxios-l10n',
'git_repository' => 'mozilla-l10n/firefoxios-l10n',
'locale_mapping' => [
'bn-IN' => 'bn',
'bn-BD' => 'bn',
Expand All @@ -60,33 +60,39 @@ class Project
'variable_patterns' => ['ios'],
],
'gecko_strings'=> [
'git_repository' => 'firefox-l10n',
'git_repository' => 'mozilla-l10n/firefox-l10n',
'git_branch' => 'main',
'source_type' => 'mixed',
'variable_patterns' => ['dtd', 'ftl', 'l10njs', 'printf', 'properties'],
],
'comm_l10n' => [
'seamonkey' => [
'git_repository' => 'seamonkey-project/seamonkey-central-l10n',
'source_type' => 'mixed',
'variable_patterns' => ['dtd', 'ftl', 'l10njs', 'printf', 'properties'],
'variable_patterns' => ['dtd', 'ftl', 'printf', 'properties'],
],
'thunderbird' => [
'git_repository' => 'thunderbird/thunderbird-l10n',
'source_type' => 'mixed',
'variable_patterns' => ['dtd', 'ftl', 'printf', 'properties'],
],
'mozilla_org' => [
'git_repository' => 'www-l10n',
'git_repository' => 'mozilla-l10n/www-l10n',
'git_branch' => 'master',
'pontoon_project' => 'mozillaorg',
'reference_locale' => 'en',
'source_type' => 'mixed',
'variable_patterns' => ['ftl'],
],
'android_l10n' => [
'git_repository' => 'android-l10n',
'git_repository' => 'mozilla-l10n/android-l10n',
'git_branch' => 'master',
'locale_mapping' => [], // To avoid using Bugzilla
'pontoon_project' => 'android-l10n',
'source_type' => 'xml',
'variable_patterns' => ['xml_android'],
],
'vpn_client' => [
'git_repository' => 'mozilla-vpn-client-l10n',
'git_repository' => 'mozilla-l10n/mozilla-vpn-client-l10n',
'underscore_locales' => true,
'pontoon_project' => 'mozilla-vpn-client',
'reference_locale' => 'en',
Expand All @@ -103,12 +109,13 @@ class Project
// Desktop products
'desktop' => [
'gecko_strings',
'comm_l10n',
'seamonkey',
'thunderbird',
],
// Products using Git
'git' => [
'android_l10n', 'firefox_ios', 'gecko_strings', 'mozilla_org',
'vpn_client',
'seamonkey', 'thunderbird', 'vpn_client',
],
// Products using free text search on Pontoon
'text_search' => [
Expand Down
51 changes: 17 additions & 34 deletions app/classes/Transvision/VersionControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public static function getPath($locale, $repo, $path)
case 'git':
$path = self::gitPath($locale, $repo, $path);
break;
case 'hg':
$path = self::hgPath($locale, $repo, $path);
break;
default:
$path = '';
break;
Expand All @@ -81,32 +78,6 @@ public static function getPath($locale, $repo, $path)
return $path;
}

/**
* Generate a path to the mercurial 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 mercurial repository
*/
public static function hgPath($locale, $repo, $path)
{
// Remove entity from path and store it in a variable
$path = explode(':', $path);
$path = $path[0];
$path = explode('/', $path);
$entity_file = array_pop($path);
$path = implode('/', $path);
$exploded_path = explode('/', $path);
$base_folder = $exploded_path[0];

# comm-l10n is the last repository using Mercurial
$url = "https://hg.mozilla.org/projects/comm-l10n/file/default/{$locale}/";

return $url . $path . '/' . $entity_file;
}

/**
* Generate a path to the GitHub repo for the file.
*
Expand All @@ -129,13 +100,25 @@ public static function gitPath($locale, $repo, $path)
$file_path = "{$repo_data['git_subfolder']}/{$file_path}";
}
if ($repo == 'gecko_strings') {
// Special case for gecko-strings (Firefox)
$file_path = explode(':', $path)[0];
if ($locale == 'en-US') {
return "https://github.com/mozilla-l10n/firefox-l10n-source/blob/main/{$file_path}";
}

return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}";
return "https://github.com/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}";
}
if ($repo == 'seamonkey') {
$file_path = explode(':', $path)[0];

return "https://gitlab.com/{$git_repo}/-/blob/{$git_branch}/{$locale}/{$file_path}";
}
if ($repo == 'thunderbird') {
$file_path = explode(':', $path)[0];
if ($locale == 'en-US') {
return "https://github.com/thunderbird/thunderbird-l10n-source/blob/main/{$file_path}";
}

return "https://github.com/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}";
}
if ($repo == 'android_l10n') {
// Special case for android-l10n (Android)
Expand All @@ -144,23 +127,23 @@ public static function gitPath($locale, $repo, $path)
: '-' . str_replace('-', '-r', $locale);
$file_path = str_replace('values', "values{$locale_android}", $file_path);

return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$file_path}";
return "https://github.com/{$git_repo}/blob/{$git_branch}/{$file_path}";
}
if ($repo == 'mozilla_org') {
// Special case for mozilla.org (Fluent)
if ($locale != 'en') {
$file_path = str_replace('en/', "{$locale}/", $file_path);
}

return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$file_path}";
return "https://github.com/{$git_repo}/blob/{$git_branch}/{$file_path}";
}
} else {
$file_path = $path;
$git_repo = $repo;
$git_branch = 'main';
}

return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}";
return "https://github.com/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}";
}

/**
Expand Down
13 changes: 9 additions & 4 deletions app/scripts/bash_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ gecko_strings_path=${local_git}/gecko_strings
gecko_strings_locales=${path_sources}/gecko_strings.txt
folders+=( $gecko_strings_path )

# Path and list of locales for comm-l10n
comm_l10n_locales=${path_sources}/comm_l10n.txt
comm_l10n_path=${local_hg}/comm_l10n
folders+=( $comm_l10n_path )
# Path and list of locales for Thunderbird
thunderbird_locales=${path_sources}/thunderbird.txt
thunderbird_path=${local_git}/thunderbird
folders+=( $thunderbird_path )

# Path and list of locales for Seamonkey
seamonkey_locales=${path_sources}/seamonkey.txt
seamonkey_path=${local_git}/seamonkey
folders+=( $seamonkey_path )

# Location of mozilla.org repository (Fluent based)
mozilla_org=$local_git/mozilla_org/
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/clean_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def main():
# Besides standard VCS folders or templates, we need to exclude some
# folders in specific projects.
excluded_folders = {
"comm_l10n": ["ja-JP-mac"],
"firefox_ios": ["templates", "es"],
"mozilla_org": ["configs", "en"],
"seamonkey": ["ja-JP-mac"],
"thunderbird": ["ja-JP-mac"],
"vpn_client": ["en"],
}

Expand Down
29 changes: 16 additions & 13 deletions app/scripts/glossaire.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fi
# Create all bash variables
source $script_path/bash_variables.sh

function updateGeckoStrings() {
function updateMultirepo() {
function buildCache() {
# Build the cache
# $1: Path containing locale folder
Expand All @@ -123,9 +123,11 @@ function updateGeckoStrings() {
nice -20 python $install/app/scripts/tmx/tmx_products.py --path $path/$locale/ --locale $locale --ref en-US --repo $repo_name
}

local repo_name="gecko_strings"
local repo_folder="$gecko_strings_path"
local locale_list="gecko_strings_locales"
local repo_name="$1"
local var_repo_path="$1_path"
local var_locales_list="$1_locales"
local repo_folder=${!var_repo_path}
local locale_list=${!var_locales_list}

# Update en-US, create TMX for en-US
git -C $repo_folder/en-US pull
Expand All @@ -139,7 +141,7 @@ function updateGeckoStrings() {

if [ "$all_locales" = true ]
then
locales=$(cat ${!locale_list})
locales=$(cat $locale_list)
else
locales=($locale_code)
fi
Expand All @@ -158,7 +160,7 @@ function updateGeckoStrings() {
done
}

function updateCommL10n() {
function updateSeamonkey() {
function buildCache() {
# Build the cache
# $1: Locale code
Expand All @@ -167,15 +169,15 @@ function updateCommL10n() {
nice -20 python $install/app/scripts/tmx/tmx_products.py --path $repo_folder/$1/ --locale $1 --ref en-US --repo $repo_name
}

local repo_name="comm_l10n"
local repo_folder="$comm_l10n_path"
local locale_list="comm_l10n_locales"
local repo_name="seamonkey"
local repo_folder="$seamonkey_path"
local locale_list="seamonkey_locales"

if [ "$checkrepo" = true ]
then
# Pull repo
echogreen "Update comm-l10n repository"
hg --cwd $repo_folder pull --update -r default
echogreen "Update seamonkey repository"
git -C $repo_folder pull
fi

# Build cache for en-US first, then other locales
Expand Down Expand Up @@ -231,8 +233,9 @@ function updateMozOrg() {
echogreen "Activating virtualenv..."
source $install/python-venv/bin/activate || exit 1

updateGeckoStrings
updateCommL10n
updateMultirepo gecko_strings
updateMultirepo thunderbird
updateSeamonkey
updateMozOrg
updateOtherProduct firefox_ios "Firefox for iOS" tmx_xliff
updateOtherProduct vpn_client "Mozilla VPN Client" tmx_xliff
Expand Down
37 changes: 29 additions & 8 deletions app/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function setupVirtualEnv() {

function initGeckoStringsRepo() {
local repo_folder="gecko_strings_path"
local repo_path="https://hg.mozilla.org/l10n-central"

# If repo_folder="gecko_strings_path", ${!repo_folder} is equal to $gecko_strings_path
cd ${!repo_folder}
Expand All @@ -62,14 +61,35 @@ function initGeckoStringsRepo() {
fi
}

function initCommL10nRepo() {
local repo_folder="comm_l10n_path"
function initThunderbirdRepo() {
local repo_folder="thunderbird_path"

if [ ! -d ${!repo_folder}/.hg ]
# If repo_folder="thunderbird_path", ${!repo_folder} is equal to $thunderbird_path
cd ${!repo_folder}

# Clone source repository as en-US
if [ ! -d "en-US" ];
then
echogreen "Checking out thunderbird-l10n-source"
git clone https://github.com/thunderbird/thunderbird-l10n-source en-US
fi

# Clone l10n monorepo as l10n
if [ ! -d "l10n" ];
then
echogreen "Checking out thunderbird-l10n"
git clone https://github.com/thunderbird/thunderbird-l10n l10n
fi
}

function initSeamonkeyRepo() {
local repo_folder="seamonkey_path"

if [ ! -d ${!repo_folder}/.git ]
then
echogreen "Checking out comm-l10n repo."
cd ${local_hg}
hg clone https://hg.mozilla.org/projects/comm-l10n/ comm_l10n
echogreen "Checking out seamonkey-central-l10n repo."
cd ${local_git}
git clone https://gitlab.com/seamonkey-project/seamonkey-central-l10n seamonkey
fi
}

Expand Down Expand Up @@ -158,7 +178,8 @@ echo "${LATEST_TAG_NAME}" | tr -d '\n' > "${install}/cache/tag.txt"

setupVirtualEnv
initGeckoStringsRepo
initCommL10nRepo
initThunderbirdRepo
initSeamonkeyRepo

# Check out GitHub repos
cd $mozilla_org
Expand Down
2 changes: 1 addition & 1 deletion tests/units/Transvision/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testGetRepositoriesNames()
public function testGetDesktopRepositories()
{
$obj = new _Project();
$repos = ['gecko_strings', 'comm_l10n'];
$repos = ['gecko_strings', 'seamonkey', 'thunderbird'];
$this
->array($obj->getDesktopRepositories())
->isEqualTo($repos);
Expand Down
Loading

0 comments on commit c81e9af

Please sign in to comment.