Skip to content

Commit

Permalink
Move po and locale directories to resources
Browse files Browse the repository at this point in the history
- Related to #18512

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Nov 30, 2023
1 parent 803fbc1 commit 6ad017d
Show file tree
Hide file tree
Showing 108 changed files with 34 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ web.config
.htaccess
# Locales
/locale/
/resources/locale/
# Temporary files to generate locales for Twig
/twig-templates/
# Backups
Expand Down
2 changes: 1 addition & 1 deletion app/vendor_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
/**
* Path to files with compiled locales (*.mo)
*/
'localePath' => ROOT_PATH . 'locale' . DIRECTORY_SEPARATOR,
'localePath' => ROOT_PATH . 'resources' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR,

/**
* Define the cache directory for routing cache and other cache files
Expand Down
10 changes: 5 additions & 5 deletions bin/generate-mo
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ else
fi

compile() {
lang=$(echo "$1" | sed 's@po/\(.*\)\.po@\1@')
lang=$(echo "$1" | sed 's@resources/po/\(.*\)\.po@\1@')
if [ -n "$stats" ] ; then
printf "%s: " "$lang"
fi
mkdir -p locale/"$lang"/LC_MESSAGES
msgfmt $stats --check -o locale/"$lang"/LC_MESSAGES/phpmyadmin.mo "$1"
mkdir -p resources/locale/"$lang"/LC_MESSAGES
msgfmt $stats --check -o resources/locale/"$lang"/LC_MESSAGES/phpmyadmin.mo "$1"
return $?
}

if [ -n "$1" ] ; then
compile po/"$1".po
compile resources/po/"$1".po
exit $?
fi

result=0
for x in po/*.po ; do
for x in resources/po/*.po ; do
compile "$x"
ret=$?
if [ $ret != 0 ] ; then
Expand Down
2 changes: 1 addition & 1 deletion bin/internal/check-release-excludes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ validateExtension() {
foundFileExt
fi
;;
locale/*)
resources/locale/*)
if [ "${extension}" != "mo" ]; then
foundFileExt
fi
Expand Down
4 changes: 2 additions & 2 deletions bin/internal/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ LC_ALL=C make -C doc html
find doc -name '*.pyc' -print0 | xargs -0 -r rm -f

# Check for gettext support
if [ -d po ] ; then
if [ -d resources/po ] ; then
echo "* Generating mo files"
./bin/generate-mo
if [ -f ./bin/remove-incomplete-mo ] ; then
Expand Down Expand Up @@ -612,7 +612,7 @@ for kit in $KITS ; do
rm phpunit.xml.*
rm .editorconfig .browserslistrc .eslintignore .jshintrc .eslintrc.json .stylelintrc.json psalm.xml psalm-baseline.xml phpstan.neon.dist phpstan-baseline.neon phpcs.xml.dist jest.config.cjs infection.json5.dist
# Gettext po files (if they were not removed by ./bin/internal/lang-cleanup.sh)
rm -rf po
rm -rf resources/po
# Documentation source code
mv doc/html htmldoc
rm -r doc
Expand Down
12 changes: 6 additions & 6 deletions bin/internal/lang-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ for type in "$@" ; do
exit 0
;;
english)
rm -rf po
rm -rf locale
rm -rf resources/po
rm -rf resources/locale
rm -rf vendor/phpmyadmin/sql-parser/locale
exit 0
;;
*)
match="$match -and -not -name $type.po -and -not -path locale/$type/LC_MESSAGES/phpmyadmin.mo -and -not -path vendor/phpmyadmin/sql-parser/locale/$type/LC_MESSAGES/sqlparser.mo"
match="$match -and -not -name $type.po -and -not -path resources/locale/$type/LC_MESSAGES/phpmyadmin.mo -and -not -path vendor/phpmyadmin/sql-parser/locale/$type/LC_MESSAGES/sqlparser.mo"
;;
esac
done

# Delete unwanted languages
# shellcheck disable=SC2086
find po locale vendor/phpmyadmin/sql-parser/locale -type f $match -print0 | xargs -0r rm
find resources/po resources/locale vendor/phpmyadmin/sql-parser/locale -type f $match -print0 | xargs -0r rm

# Delete empty directories
rmdir --ignore-fail-on-non-empty locale/*/*
rmdir --ignore-fail-on-non-empty locale/*
rmdir --ignore-fail-on-non-empty resources/locale/*/*
rmdir --ignore-fail-on-non-empty resources/locale/*
rmdir --ignore-fail-on-non-empty vendor/phpmyadmin/sql-parser/locale/*/*
rmdir --ignore-fail-on-non-empty vendor/phpmyadmin/sql-parser/locale/*
2 changes: 1 addition & 1 deletion bin/internal/locales-contributors
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -n "$GATEWAY_INTERFACE" ] ; then
exit 1
fi

for x in po/*.po ; do
for x in resources/po/*.po ; do
grep 'Team' "$x" | sed 's/.*: \(.*\)<.*/\1/'
git shortlog -sne --no-merges -- "$x" | grep '^ [ 0-9][0-9]\{3\}'
done
10 changes: 5 additions & 5 deletions bin/remove-incomplete-mo
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fi

check() {
TMPOUTPUTFILE=$2
lang=$(echo "$1" | sed 's@po/\(.*\)\.po@\1@')
lang=$(echo "$1" | sed 's@resources/po/\(.*\)\.po@\1@')
STATS=$(LC_ALL=C msgfmt --statistics -o /dev/null "$1" 2>&1)
if echo "$STATS" | grep -q ' translated ' ; then
TRANSLATED=$(echo "$STATS" | sed 's/\(^\|.* \)\([0-9]*\) translated.*/\2/')
Expand All @@ -60,13 +60,13 @@ check() {

if [ "$PERCENT" -lt "$THRESHOLD" ] ; then
echo "Removing $lang, only $PERCENT%"
rm -f locale/"$lang"/LC_MESSAGES/phpmyadmin.mo
rmdir locale/"$lang"/LC_MESSAGES
rmdir locale/"$lang"
rm -f resources/locale/"$lang"/LC_MESSAGES/phpmyadmin.mo
rmdir resources/locale/"$lang"/LC_MESSAGES
rmdir resources/locale/"$lang"
fi
}

for x in po/*.po ; do
for x in resources/po/*.po ; do
check "$x" "$TMPOUTPUTFILE"
done

Expand Down
14 changes: 7 additions & 7 deletions bin/update-po
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ rm -rf twig-templates/
php bin/console cache:warmup --twig-po --env development

# Update pot (template), ensure that advisor is at the end
LOCS=$(find po -name '*.po' | sed 's@.*/\(.*\)\.po@\1@')
LOCS=$(find resources/po -name '*.po' | sed 's@.*/\(.*\)\.po@\1@')

find . -name '*.php' -not -path './tests/*' -not -path './po/*' -not -path './tmp/*' -not -path './release/*' -not -path './node_modules/*' -not -path './vendor/*' > twig-templates/filesList
find . -name '*.php' -not -path './tests/*' -not -path './resources/po/*' -not -path './tmp/*' -not -path './release/*' -not -path './node_modules/*' -not -path './vendor/*' > twig-templates/filesList

php ./bin/match-twig-cache
sort --dictionary-order --ignore-case --output ./twig-templates/filesListTemp < ./twig-templates/filesList
Expand All @@ -30,7 +30,7 @@ php ./bin/match-twig-cache --reverse
xgettext \
-d phpmyadmin \
--msgid-bugs-address=translators@phpmyadmin.net \
-o po/phpmyadmin.pot \
-o resources/po/phpmyadmin.pot \
--language=PHP \
--add-comments=l10n \
--add-location \
Expand Down Expand Up @@ -58,7 +58,7 @@ sed -i.~ '
s/PACKAGE/phpMyAdmin/;
s/(C) YEAR/(C) 2003 - '"$(date +%Y)"'/;
s/VERSION/'"$ver"'/;
' po/phpmyadmin.pot
' resources/po/phpmyadmin.pot

# Update po files (translations)
for loc in $LOCS ; do
Expand All @@ -68,12 +68,12 @@ for loc in $LOCS ; do
s/(C) YEAR/(C) 2003 - '"$(date +%Y)"'/;
s/VERSION/'"$ver"'/;
s/Project-Id-Version: phpMyAdmin .*/Project-Id-Version: phpMyAdmin '"$ver"'\\n"/;
' po/"$loc".po
msgmerge --previous -U po/"$loc".po po/phpmyadmin.pot
' resources/po/"$loc".po
msgmerge --previous -U resources/po/"$loc".po resources/po/phpmyadmin.pot
done

# Commit changes
git add po/*.po po/phpmyadmin.pot
git add resources/po/*.po resources/po/phpmyadmin.pot
git commit -s -m 'Update po files
[ci skip]'
2 changes: 1 addition & 1 deletion config.sample.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

/**
* Default language to use, if not browser-defined or user-defined
* (you find all languages in the locale folder)
* (you find all languages in the 'resources/locale' folder)
* uncomment the desired line:
* default = 'en'
*/
Expand Down
4 changes: 2 additions & 2 deletions doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,7 @@ Languages

Defines the default language to use, if not browser-defined or user-
defined. The corresponding language file needs to be in
locale/*code*/LC\_MESSAGES/phpmyadmin.mo.
resources/locale/*code*/LC\_MESSAGES/phpmyadmin.mo.

.. config:option:: $cfg['DefaultConnectionCollation']
Expand All @@ -2979,7 +2979,7 @@ Languages
:default: not set

Force language to use. The corresponding language file needs to be in
locale/*code*/LC\_MESSAGES/phpmyadmin.mo.
resources/locale/*code*/LC\_MESSAGES/phpmyadmin.mo.

.. config:option:: $cfg['FilterLanguages']
Expand Down
2 changes: 1 addition & 1 deletion doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ Some users have requested to be able to reduce the size of the phpMyAdmin instal
This is not recommended and could lead to confusion over missing features, but can be done.
A list of files and corresponding functionality which degrade gracefully when removed include:

* :file:`./locale/` folder, or unused subfolders (interface translations)
* :file:`./resources/locale/` folder, or unused subfolders (interface translations)
* Any unused themes in :file:`./public/themes/` except the default theme `pmahomme`.
* :file:`./app/language_stats.inc.php` (translation statistics)
* :file:`./doc/` (documentation)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Command/FixPoTwigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#[AsCommand(name: 'fix-po-twig', description: 'Fixes POT file for Twig templates.')]
final class FixPoTwigCommand extends Command
{
private const POT_FILE = ROOT_PATH . 'po/phpmyadmin.pot';
private const POT_FILE = ROOT_PATH . 'resources/po/phpmyadmin.pot';
private const REPLACE_FILE = ROOT_PATH . 'twig-templates/replace.json';

protected function configure(): void
Expand Down

0 comments on commit 6ad017d

Please sign in to comment.