From b2f669fb161ff4bdba9ba2528241312d037503e6 Mon Sep 17 00:00:00 2001 From: Jane Sandberg <sandbej@linnbenton.edu> Date: Mon, 29 Jul 2019 11:56:31 -0700 Subject: [PATCH] LP1802593: Correct formatting of language code in Angularjs, KPAC EgWeb offers two different formats of the current locale: ctx.locale and ctx.eg_locale. This commit configures the lang attribute in AngularJS staff client, OPAC, and KPAC to use eg_locale, since it has the appropriate format (e.g. en-US, fr-CA). Also adds some tests for EgWeb's handling of language codes. Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu> Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> --- Open-ILS/src/perlmods/t/15-OpenILS-WWW.t | 5 ++++- Open-ILS/src/templates/base.tt2 | 2 +- Open-ILS/src/templates/kpac/parts/base.tt2 | 2 +- Open-ILS/src/templates/opac/parts/base.tt2 | 2 +- Open-ILS/src/templates/staff/base.tt2 | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/t/15-OpenILS-WWW.t b/Open-ILS/src/perlmods/t/15-OpenILS-WWW.t index d55e809519..f78a4fa4a8 100644 --- a/Open-ILS/src/perlmods/t/15-OpenILS-WWW.t +++ b/Open-ILS/src/perlmods/t/15-OpenILS-WWW.t @@ -1,6 +1,6 @@ #!perl -T -use Test::More tests => 9; +use Test::More tests => 11; use_ok( 'OpenILS::WWW::BadDebt' ); use_ok( 'OpenILS::WWW::EGWeb' ); @@ -11,3 +11,6 @@ use_ok( 'OpenILS::WWW::Redirect' ); use_ok( 'OpenILS::WWW::TemplateBatchBibUpdate' ); use_ok( 'OpenILS::WWW::Vandelay' ); use_ok( 'OpenILS::WWW::XMLRPCGateway' ); + +is( OpenILS::WWW::EGWeb::parse_eg_locale('hy_am'), 'hy-AM', 'correctly formatted Armenian language code' ); +is( OpenILS::WWW::EGWeb::parse_eg_locale(), 'en-US', 'correctly formatted default language code' ); diff --git a/Open-ILS/src/templates/base.tt2 b/Open-ILS/src/templates/base.tt2 index a6f4b8c8bb..ee988bb312 100644 --- a/Open-ILS/src/templates/base.tt2 +++ b/Open-ILS/src/templates/base.tt2 @@ -1,5 +1,5 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns='http://www.w3.org/1999/xhtml' lang='[% ctx.locale %]' xml:lang='[% ctx.locale %]'> +<html xmlns='http://www.w3.org/1999/xhtml' lang='[% ctx.eg_locale %]' xml:lang='[% ctx.eg_locale %]'> <head> <title>[% ctx.page_title %]</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> diff --git a/Open-ILS/src/templates/kpac/parts/base.tt2 b/Open-ILS/src/templates/kpac/parts/base.tt2 index 94364c643b..4711c3f73a 100644 --- a/Open-ILS/src/templates/kpac/parts/base.tt2 +++ b/Open-ILS/src/templates/kpac/parts/base.tt2 @@ -1,5 +1,5 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns='http://www.w3.org/1999/xhtml' lang='[% ctx.locale %]' xml:lang='[% ctx.locale %]'> +<html xmlns='http://www.w3.org/1999/xhtml' lang='[% ctx.eg_locale %]' xml:lang='[% ctx.eg_locale %]'> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="[% ctx.media_prefix %]/css/skin/default/kpac/style.css[% ctx.cache_key %]" /> diff --git a/Open-ILS/src/templates/opac/parts/base.tt2 b/Open-ILS/src/templates/opac/parts/base.tt2 index aa12e39ebe..b28f45ceb8 100644 --- a/Open-ILS/src/templates/opac/parts/base.tt2 +++ b/Open-ILS/src/templates/opac/parts/base.tt2 @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang='[% ctx.locale.replace('_', '-') %]'> +<html lang='[% ctx.eg_locale %]'> <head prefix="og: http://ogp.me/ns#"> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> diff --git a/Open-ILS/src/templates/staff/base.tt2 b/Open-ILS/src/templates/staff/base.tt2 index 7ce42ae73f..78b393b37f 100644 --- a/Open-ILS/src/templates/staff/base.tt2 +++ b/Open-ILS/src/templates/staff/base.tt2 @@ -1,6 +1,6 @@ <!doctype html> [%- PROCESS 'staff/config.tt2' %] -<html lang="[% ctx.locale %]" +<html lang="[% ctx.eg_locale %]" [%- IF ctx.page_app %] ng-app="[% ctx.page_app %]"[% END -%] [%- IF ctx.page_ctrl %] ng-controller="[% ctx.page_ctrl %]"[% END %]> <head> -- 2.11.0