gnucash-htdocs beta: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Thu Jul 7 18:29:29 EDT 2022
Updated via https://github.com/Gnucash/gnucash-htdocs/commit/4f16cd61 (commit)
via https://github.com/Gnucash/gnucash-htdocs/commit/ed74076f (commit)
via https://github.com/Gnucash/gnucash-htdocs/commit/6ec7bb2c (commit)
via https://github.com/Gnucash/gnucash-htdocs/commit/31227423 (commit)
via https://github.com/Gnucash/gnucash-htdocs/commit/923e6fb7 (commit)
from https://github.com/Gnucash/gnucash-htdocs/commit/852bcfb8 (commit)
commit 4f16cd611ccd12e862898d9d6f792d148ca67504
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Jul 7 15:24:16 2022 -0700
Refactor locale detection.
Parse all language strings the same regardless of source.
Use language quality factors if included.
diff --git a/lang.php b/lang.php
index f1848ac..7f1ec8e 100644
--- a/lang.php
+++ b/lang.php
@@ -2,6 +2,27 @@
$top_dir = ".";
$locale_dir = "locale";
+# key: locale, value: lang_dir
+$supported_languages = array(
+ 'ca_ES' => 'ca',
+ 'de_DE' => 'de',
+ 'en_US' => 'en',
+ 'es_ES' => 'es',
+ 'fr_FR' => 'fr',
+ 'he_IL' => 'he',
+ 'hr_HR' => 'hr',
+ 'hu_HU' => 'hu',
+ 'id_ID' => 'id',
+ 'it_IT' => 'it',
+ 'ja_JP' => 'ja',
+ 'nb_NO' => 'nb',
+ 'nl_NL' => 'nl',
+ 'pl_PL' => 'pl',
+ 'pt_PT' => 'pt',
+ 'zh_CN' => 'zh_CN',
+ 'zh_TW' => 'zh_TW'
+);
+
if (!array_key_exists('HTTP_HOST', $_SERVER) || ($_SERVER["HTTP_HOST"] == "lists.gnucash.org"))
{
$home = "https://www.gnucash.org";
@@ -21,76 +42,52 @@ if (array_key_exists('lang_cookie', $_COOKIE)) {
}
# allow user override.
-$get_lang = filter_input(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
-
-if ($get_lang) { $locale = $get_lang; }
+$languages = filter_input(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
# choose a default language based on the client browser's preferred
# language list
#echo ("<!-- top_dir: $top_dir, me: ".__FILE__."-->\n");
+# Find the locale from Client Accept language
+# Get user preferred languages, and match against supported language
+if ($languages == "" and isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) )
+{
+ # tolower() => remove space => '-' -> '_'
+ $accept_language = filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE', FILTER_SANITZE_STRING);
+ $languages = str_replace('-','_', str_replace(' ', '', strtolower($accept_language)));
+}
-# key: locale, value: lang_dir
-$supported_languages = array(
- 'ca_ES' => 'ca',
- 'de_DE' => 'de',
- 'en_US' => 'en',
- 'es_ES' => 'es',
- 'fr_FR' => 'fr',
- 'he_IL' => 'he',
- 'hr_HR' => 'hr',
- 'hu_HU' => 'hu',
- 'id_ID' => 'id',
- 'it_IT' => 'it',
- 'ja_JP' => 'ja',
- 'nb_NO' => 'nb',
- 'nl_NL' => 'nl',
- 'pl_PL' => 'pl',
- 'pt_PT' => 'pt',
- 'zh_CN' => 'zh_CN',
- 'zh_TW' => 'zh_TW'
-);
-
-# Find the full locale name for short language name.
-if (strlen($locale) == 2) {
- foreach($supported_languages as $loc_lang => $loc_dir)
+$ranked_langs = [];
+$languages = explode(",", $languages);
+if (count($languages) > 1) {
+ foreach ($languages as $item)
{
- if ( (strtolower($locale) == strtolower($loc_dir))
- || (strtolower($locale) == substr($loc_lang, 0, 2 )) )
- {
- $locale = $loc_lang;
- break;
+ $parts = explode(";", $item);
+ if (!$parts[1]) {
+ $ranked_langs[$parts[0]] = 1.0;
+ } else {
+ $ranked_langs[$parts[0]] = substr($parts[1], 2, NULL);
}
}
+ arsort($ranked_langs, SORT_NUMERIC);
+} else {
+ $ranked_langs[$languages] = 1;
}
-
-# Find the locale from Client Accept language
-if ($locale == "") {
- # Get user preferred languages, and match against supported language
- if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) )
+foreach (array_keys($ranked_langs) as $lang) {
+ if ($ranked_langs[$lang] == 0) {
+ break;
+ }
+ $lang_short = substr($lang, 0, 2);
+ # full match is prefer, but short match is acceptable.
+ foreach ($supported_languages as $loc_lang => $loc_dir)
{
- # tolower() => remove space => '-' -> '_'
- # "fr-ch;q=0.3, en, zh-cn;q=0.7" => "fr_ch;q=0.3,en,zh_cn;q=0.7"
- $accept_language = filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE', FILTER_SANITZE_STRING);
- $languages = str_replace('-','_', str_replace(' ', '', strtolower($accept_language)));
- $languages = explode(",", $languages);
- foreach ($languages as $item)
- {
- # "zh_cn;q=0.7" => "zh_cn"
- $lang = substr($item, 0, strcspn($item, ';'));
- $lang_short = substr($lang, 0, 2);
- # full match is prefer, but short match is acceptable.
- foreach ($supported_languages as $loc_lang => $loc_dir)
- {
- if ($lang == strtolower($loc_lang)) { $locale = $loc_lang; break; }
- if ($lang_short == substr($loc_lang, 0, 2 )) { $locale = $loc_lang; }
- }
- if ($locale != "") { break; }
- }
+ if ($lang == strtolower($loc_lang)) { $locale = $loc_lang; break; }
+ if ($lang_short == substr($loc_lang, 0, 2 )) { $locale = $loc_lang; }
}
- # nothing matched, use default language
- if ($locale == "") { $locale = "en_US"; }
+ if ($locale != "") { break; }
}
+# nothing matched, use default language
+if ($locale == "") { $locale = "en_US"; }
$lang_dir = array_key_exists($locale, $supported_languages) ?
$supported_languages[$locale] : "en";
commit ed74076f0505e9b171153f8a1c4f30e88a6b1218
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Jul 7 14:26:57 2022 -0700
Filter language cookie and HTTP_ACCEPT_LANGUAGE_HEADER.
To prevent attacks with forged cookies or headers.
diff --git a/lang.php b/lang.php
index c46e59d..f1848ac 100644
--- a/lang.php
+++ b/lang.php
@@ -14,7 +14,7 @@ if ( !isset($lang_dir) ) { $lang_dir = $locale; }
# get the cookie setting
if (array_key_exists('lang_cookie', $_COOKIE)) {
- $locale = $_COOKIE['lang_cookie'];
+ $locale = filter_input(INPUT_COOKIE, 'lang_cookie', FILTER_SANITIZE_STRING);
$lang_cookie = $locale;
}else{
$lang_cookie = "";
@@ -32,31 +32,31 @@ if ($get_lang) { $locale = $get_lang; }
# key: locale, value: lang_dir
$supported_languages = array(
- 'ca_ES' => 'ca',
- 'de_DE' => 'de',
- 'en_US' => 'en',
- 'es_ES' => 'es',
- 'fr_FR' => 'fr',
- 'he_IL' => 'he',
- 'hr_HR' => 'hr',
- 'hu_HU' => 'hu',
- 'id_ID' => 'id',
- 'it_IT' => 'it',
- 'ja_JP' => 'ja',
- 'nb_NO' => 'nb',
- 'nl_NL' => 'nl',
- 'pl_PL' => 'pl',
- 'pt_PT' => 'pt',
- 'zh_CN' => 'zh_CN',
- 'zh_TW' => 'zh_TW'
- );
+ 'ca_ES' => 'ca',
+ 'de_DE' => 'de',
+ 'en_US' => 'en',
+ 'es_ES' => 'es',
+ 'fr_FR' => 'fr',
+ 'he_IL' => 'he',
+ 'hr_HR' => 'hr',
+ 'hu_HU' => 'hu',
+ 'id_ID' => 'id',
+ 'it_IT' => 'it',
+ 'ja_JP' => 'ja',
+ 'nb_NO' => 'nb',
+ 'nl_NL' => 'nl',
+ 'pl_PL' => 'pl',
+ 'pt_PT' => 'pt',
+ 'zh_CN' => 'zh_CN',
+ 'zh_TW' => 'zh_TW'
+);
# Find the full locale name for short language name.
if (strlen($locale) == 2) {
foreach($supported_languages as $loc_lang => $loc_dir)
{
if ( (strtolower($locale) == strtolower($loc_dir))
- || (strtolower($locale) == substr($loc_lang, 0, 2 )) )
+ || (strtolower($locale) == substr($loc_lang, 0, 2 )) )
{
$locale = $loc_lang;
break;
@@ -66,33 +66,30 @@ if (strlen($locale) == 2) {
# Find the locale from Client Accept language
if ($locale == "") {
- # Get user preferred languages, and match against supported language
- if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) )
+ # Get user preferred languages, and match against supported language
+ if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) )
+ {
+ # tolower() => remove space => '-' -> '_'
+ # "fr-ch;q=0.3, en, zh-cn;q=0.7" => "fr_ch;q=0.3,en,zh_cn;q=0.7"
+ $accept_language = filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE', FILTER_SANITZE_STRING);
+ $languages = str_replace('-','_', str_replace(' ', '', strtolower($accept_language)));
+ $languages = explode(",", $languages);
+ foreach ($languages as $item)
{
- # tolower() => remove space => '-' -> '_'
- # "fr-ch;q=0.3, en, zh-cn;q=0.7" => "fr_ch;q=0.3,en,zh_cn;q=0.7"
- /* Todo: use Locale::canonicalize ( string $locale ) : string instead
- * See https://www.php.net/manual/en/locale.canonicalize.php
- * Full description: https://unicode-org.github.io/icu/userguide/locale/#canonicalization
- * if ICU is installed on the server */
- $languages = str_replace('-','_', str_replace(' ', '', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
- $languages = explode(",", $languages);
- foreach ($languages as $item)
- {
- # "zh_cn;q=0.7" => "zh_cn"
- $lang = substr($item, 0, strcspn($item, ';'));
- $lang_short = substr($lang, 0, 2);
- # full match is prefer, but short match is acceptable.
- foreach ($supported_languages as $loc_lang => $loc_dir)
- {
- if ($lang == strtolower($loc_lang)) { $locale = $loc_lang; break; }
- if ($lang_short == substr($loc_lang, 0, 2 )) { $locale = $loc_lang; }
- }
- if ($locale != "") { break; }
- }
+ # "zh_cn;q=0.7" => "zh_cn"
+ $lang = substr($item, 0, strcspn($item, ';'));
+ $lang_short = substr($lang, 0, 2);
+ # full match is prefer, but short match is acceptable.
+ foreach ($supported_languages as $loc_lang => $loc_dir)
+ {
+ if ($lang == strtolower($loc_lang)) { $locale = $loc_lang; break; }
+ if ($lang_short == substr($loc_lang, 0, 2 )) { $locale = $loc_lang; }
+ }
+ if ($locale != "") { break; }
}
- # nothing matched, use default language
- if ($locale == "") { $locale = "en_US"; }
+ }
+ # nothing matched, use default language
+ if ($locale == "") { $locale = "en_US"; }
}
$lang_dir = array_key_exists($locale, $supported_languages) ?
commit 6ec7bb2c80e77e792848627fbc5887c0ec71c260
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Jul 7 14:11:08 2022 -0700
Test locale against lang array keys.
Prevents error messages for invalid/unsupported locales.
diff --git a/lang.php b/lang.php
index 794558d..c46e59d 100644
--- a/lang.php
+++ b/lang.php
@@ -95,7 +95,8 @@ if ($locale == "") {
if ($locale == "") { $locale = "en_US"; }
}
-$lang_dir = $supported_languages[$locale];
+$lang_dir = array_key_exists($locale, $supported_languages) ?
+ $supported_languages[$locale] : "en";
setcookie("lang_cookie", $locale);
# We should have a locale now, let's set up the required bits and pieces to show
commit 3122742379b1518042866ab113077ed0f2456e79
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Jul 2 13:28:23 2022 -0700
Release gnucash-4.11-1.setup.exe
Fixes https://bugs.gnucash.org/show_bug.cgi?id=798559
diff --git a/externals/global_params.php b/externals/global_params.php
index f4a6480..fb2ec9a 100644
--- a/externals/global_params.php
+++ b/externals/global_params.php
@@ -12,7 +12,7 @@
$latest_stable = $major_stable.".".$minor_stable;
//$latest_stable_win = $latest_stable;
- $latest_stable_win = $latest_stable;
+ $latest_stable_win = $latest_stable."-1";
$latest_stable_mac_intel = $latest_stable."-1";
// Change this when there has been a re-tag to add the re-tag letter,
// e.g. if one retagged 2.6.13 to 2.6.13a, make $tarball = $latest_stable."a".
diff --git a/news/220626-4.11.news b/news/220626-4.11.news
index ece4a0a..9164081 100644
--- a/news/220626-4.11.news
+++ b/news/220626-4.11.news
@@ -109,7 +109,7 @@
<ul>
<li><code>f814ede30d7be0dec0afb2ae8d03628b9ae34c848b68312e4c5aded94c102b19</code> gnucash-4.11.tar.bz2</li>
<li><code>6ff4f408ff05c85c8dcdac43d0ac16672bf2059a21928de08e0f860d437c8f83</code> gnucash-4.11.tar.gz</li>
- <li><code>4bb6b616285ae4ddb286595b4270dc1c3e26045bc56d53227d4f6280535c6770</code> gnucash-4.11.setup.exe</li>
+ <li><code>63d98c5873e58191cbac5c6ba4f269528c67911d0d63e2dd114e2f1c12c328a7</code> gnucash-4.11-1.setup.exe</li>
<li><code>cd51a9c0cf1edb378c6252853969ea4f9ecc95c5d8547fd7f76b322407b0ca72</code> Gnucash-Intel-4.11-1.dmg</li>
<li><code>a83b8ef39111961d805100a860053557a1166cbf0b93a66dfb2c3f732ec25898</code> gnucash-docs-4.11.tar.gz</li>
</ul>
@@ -117,12 +117,12 @@
<ul>
<li>SourceForge:
<ul>
- <li><a href="https://downloads.sourceforge.net/gnucash/gnucash%20%28stable%29/4.11/gnucash-4.11.setup.exe">Win32</a></li>
+ <li><a href="https://downloads.sourceforge.net/gnucash/gnucash%20%28stable%29/4.11/gnucash-4.11-1.setup.exe">Win32</a></li>
<li><a href="https://downloads.sourceforge.net/gnucash/gnucash%20%28stable%29/4.11/Gnucash-Intel-4.11-1.dmg">Mac-Intel</a></li>
</ul></li>
<li>Github
<ul>
- <li><a href="https://github.com/Gnucash/gnucash/releases/download/4.11/gnucash-4.11.setup.exe">Win32</a></li>
+ <li><a href="https://github.com/Gnucash/gnucash/releases/download/4.11/gnucash-4.11-1.setup.exe">Win32</a></li>
<li><a href="https://github.com/Gnucash/gnucash/releases/download/4.11/Gnucash-Intel-4.11-1.dmg">Mac-Intel</a></li>
</ul></li></ul>
commit 923e6fb7295981e3a9bcf17c781db557c82992c3
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date: Mon Jun 27 23:49:57 2022 +0200
Amend announcement: Replace XXX by 4.11
diff --git a/news/220626-4.11.news b/news/220626-4.11.news
index f2311e8..ece4a0a 100644
--- a/news/220626-4.11.news
+++ b/news/220626-4.11.news
@@ -71,7 +71,7 @@
<h2>Documentation</h2>
<p>Concurrent with the release of GnuCash 4.11 we're pleased to also release a new version of the companion Help and Tutorial and Concepts Guide</p>
-<h4>Between 4.10.1 and XXX, the following bugfixes were accomplished:</h4>
+<h4>Between 4.10.1 and 4.11, the following bugfixes were accomplished:</h4>
<ul>
<li><a href="https://bugs.gnucash.org/show_bug.cgi?id=798414">Bug 798414 -No way to get whole of account column displayed</a></li>
</ul>
Summary of changes:
externals/global_params.php | 2 +-
lang.php | 123 +++++++++++++++++++++-----------------------
news/220626-4.11.news | 8 +--
3 files changed, 64 insertions(+), 69 deletions(-)
More information about the gnucash-changes
mailing list