Skip to content

Commit

Permalink
fix: fixes to have build_lang running
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel committed Nov 23, 2021
1 parent 3326469 commit c99538b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ ENV PATH="/opt/perl/local/bin:${PATH}"
RUN \
mkdir -p var/run/apache2/ && \
chown www-data:www-data var/run/apache2/ && \
for path in users products product_images orgs new_images logs; do \
for path in data html_data users products product_images orgs new_images logs tmp; do \
mkdir -p /mnt/podata/${path}; \
done && \
chown www-data:www-data -R /mnt/podata && \
Expand Down
6 changes: 3 additions & 3 deletions lib/ProductOpener/Lang.pm
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ PO

# Load stored %Lang from Lang.sto

my $path = "$data_root/Lang.${server_domain}.sto";
my $path = "$data_root/data/Lang.${server_domain}.sto";
if (-e $path) {

$log->info("Loading \%Lang", { path => $path }) if $log->is_info();
my $lang_ref = retrieve("$data_root/Lang.${server_domain}.sto");
my $lang_ref = retrieve($path);
%Lang = %{$lang_ref};
$log->info("Loaded \%Lang", { path => $path }) if $log->is_info();

Expand All @@ -409,7 +409,7 @@ if (-e $path) {
sleep(1) if $log->is_info();
}
else {
$log->warn("File does not exist, \%Lang will be empty. Run scripts/build_lang.pm to fix this.", { path => $path }) if $log->is_warn();
$log->warn("Language translation file does not exist, \%Lang will be empty. Run scripts/build_lang.pm to fix this.", { path => $path }) if $log->is_warn();
}


Expand Down
5 changes: 4 additions & 1 deletion scripts/build_lang.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
# use $server_domain in part of the name so that we have different files
# when 2 instances of Product Opener share the same $data_root
# as is the case with world.openfoodfacts.org and world.preprod.openfoodfacts.org
store("$data_root/Lang.${server_domain}.sto",\%Lang);
if (! -e "$data_root/data") {
mkdir("$data_root/data", 0755) or die("Could not create target directory $data_root/data : $!\n");
}
store("$data_root/data/Lang.${server_domain}.sto",\%Lang);

# Generate JSON files for JavaScript I18N
ProductOpener::Lang::build_json();
Expand Down

0 comments on commit c99538b

Please sign in to comment.