Document steps for migrating localization-docs from 'master' to 'main' #67

Open
opened 2026-05-06 17:22:51 +00:00 by rffontenelle · 1 comment
Member

Before migrating the fedora docs l10n repositories from master branch to main, some steps are required to avoid losing translations. For instance, simply renaming the branch and rebuilding translations will cause all 'po//master/' to be removed and 'po//main/' to created from scratch.

It is also interesting to document steps to fix a migration the caused the loss of translations, so they can be used in case it happens.

Before migrating the fedora docs l10n repositories from master branch to main, some steps are required to avoid losing translations. For instance, simply renaming the branch and rebuilding translations will cause all 'po/*/master/' to be removed and 'po/*/main/' to created from scratch. It is also interesting to document steps to fix a migration the caused the loss of translations, so they can be used in case it happens.
Author
Member

These are the steps I used to restore project when the migration removed all 'master' directories, consequently losing all po files.

# First, *lock* all the project's components in Weblate and *commit* and *push*
# all contributions to the l10n repository.

# Clone repository and make a local copy repository.
git clone https://forge.fedoraproject.org/localization-docs/project
cp -a project project-pre-main

# Find the last commit before the removal of 'master' directories and 
# make the local copy repository check it out  
git -C project-pre-main checkout 2656da8f4499fe7837e35e6a153368e973742317

# List PO files from the repository ('main' branch) 
main_po_files=$(find project/po/*/main -name '*.po' | sort)

# 1) merge translations from master branch,
# 2) updating source strings using .pot files from main branch, and
# 3) store the result into .po files from main branch.
for main_po in $main_po_files; do
  master_po=$(echo $main_po | sed 's|^project|project-pre-main|;s|/main/|/master/|')
  main_pot=$(echo $main_po | sed 's|^project/po/.*/main|project/pot/main|;s|$|t|')

  test -f $master_po || { echo "master PO not found: $master_po"; continue; }
  test -f $main_pot || { echo "POT not found: $main_pot"; continue; }

  printf "$main_po "; msgmerge $master_po $main_pot > $main_po
done

# Take a look at the 'git diff' output for something that needs fixing
git -C project diff
 
# Consider the following fixes to reduce noise in the commit message:

# Files in the repository had ./pages/.. and ./nav.adoc, but msgmerge
# removed them.  Re-adding to reduce noise. 
sed -i 's| pages/| ./pages/|g' project/po/**/*.po
sed -i 's| nav.adoc| ./nav.adoc|' project/po/**/*.po

# 'project' repository had attributes.po file without translation strings.
# Not an error since the source file is empty. The repository had only
# Gettext headers which msgmerge removed.
# No header results in just warnings, but empty file is error
(cd project && git checkout $(find -name attributes.po);)
These are the steps I used to restore [project](https://forge.fedoraproject.org/localization-docs/project) when the migration removed all 'master' directories, consequently losing all po files. ```bash # First, *lock* all the project's components in Weblate and *commit* and *push* # all contributions to the l10n repository. # Clone repository and make a local copy repository. git clone https://forge.fedoraproject.org/localization-docs/project cp -a project project-pre-main # Find the last commit before the removal of 'master' directories and # make the local copy repository check it out git -C project-pre-main checkout 2656da8f4499fe7837e35e6a153368e973742317 # List PO files from the repository ('main' branch) main_po_files=$(find project/po/*/main -name '*.po' | sort) # 1) merge translations from master branch, # 2) updating source strings using .pot files from main branch, and # 3) store the result into .po files from main branch. for main_po in $main_po_files; do master_po=$(echo $main_po | sed 's|^project|project-pre-main|;s|/main/|/master/|') main_pot=$(echo $main_po | sed 's|^project/po/.*/main|project/pot/main|;s|$|t|') test -f $master_po || { echo "master PO not found: $master_po"; continue; } test -f $main_pot || { echo "POT not found: $main_pot"; continue; } printf "$main_po "; msgmerge $master_po $main_pot > $main_po done # Take a look at the 'git diff' output for something that needs fixing git -C project diff # Consider the following fixes to reduce noise in the commit message: # Files in the repository had ./pages/.. and ./nav.adoc, but msgmerge # removed them. Re-adding to reduce noise. sed -i 's| pages/| ./pages/|g' project/po/**/*.po sed -i 's| nav.adoc| ./nav.adoc|' project/po/**/*.po # 'project' repository had attributes.po file without translation strings. # Not an error since the source file is empty. The repository had only # Gettext headers which msgmerge removed. # No header results in just warnings, but empty file is error (cd project && git checkout $(find -name attributes.po);) ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
localization/tickets#67
No description provided.