Skip to content

Commit

Permalink
[fc] Repository: plone.formwidget.recurrence
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2021-09-02T12:23:41-03:00
Author: Franco Pellegrini (frapell) <[email protected]>
Commit: plone/plone.formwidget.recurrence@5c9320a

Fix batch numbers computation. fixes gh-25

Files changed:
A news/25.bugfix
M plone/formwidget/recurrence/browser/json_recurrence.py
Repository: plone.formwidget.recurrence

Branch: refs/heads/master
Date: 2021-10-14T12:42:39+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: plone/plone.formwidget.recurrence@2761300

Merge pull request #27 from plone/frapell-batch-compute-master

Fix batch numbers computation (Master)

Files changed:
A news/25.bugfix
M plone/formwidget/recurrence/browser/json_recurrence.py
  • Loading branch information
jensens committed Oct 14, 2021
1 parent 6fdeef5 commit 9ea13c6
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,34 @@
Repository: plone.i18n
Repository: plone.formwidget.recurrence


Branch: refs/heads/4.x
Date: 2021-09-07T16:16:18+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.i18n/commit/ed1343aaf2582b321d55ba86cd3ab168007236a7
Branch: refs/heads/master
Date: 2021-09-02T12:23:41-03:00
Author: Franco Pellegrini (frapell) <[email protected]>
Commit: https://github.com/plone/plone.formwidget.recurrence/commit/5c9320a17bf7706d01beb742a9ca41c8dffd4b37

Support Cyrillic and Latin character sets for Serbian.

See https://github.com/collective/plone.app.locales/issues/326

Let 'sr' be general Serbian. Can be Latin or Cyrillic.
You can influence which character set is used, by choosing one of three values in an environment variable:

```
zope_i18n_allowed_languages sr
zope_i18n_allowed_languages sr@Cyrl
zope_i18n_allowed_languages sr@Latn
```

Default character set in Plone 5.2 is Cyrillic, but this may change to Latin in 6.0.
Fix batch numbers computation. fixes gh-25

Files changed:
A news/326.feature
M plone/i18n/locales/languages.py
A news/25.bugfix
M plone/formwidget/recurrence/browser/json_recurrence.py

b'diff --git a/news/326.feature b/news/326.feature\nnew file mode 100644\nindex 0000000..784a46f\n--- /dev/null\n+++ b/news/326.feature\n@@ -0,0 +1,3 @@\n+Support Cyrillic and Latin character sets for Serbian.\n+See `locales issue 326 <https://github.com/collective/plone.app.locales/issues/326>`_.\n+[maurits, fredvd]\ndiff --git a/plone/i18n/locales/languages.py b/plone/i18n/locales/languages.py\nindex 0ffec69..69a06a5 100644\n--- a/plone/i18n/locales/languages.py\n+++ b/plone/i18n/locales/languages.py\n@@ -4,6 +4,7 @@\n from plone.i18n.locales.interfaces import IMetadataLanguageAvailability\n from zope.interface import implementer\n \n+import os\n import six\n \n \n@@ -469,6 +470,8 @@ class MetadataLanguageAvailability(LanguageAvailability):\n u\'flag\': u\'/++resource++country-flags/al.gif\',\n },\n u\'sr\': {\n+ # Note: we support two character sets for this language.\n+ # See zope_i18n_allowed_languages below.\n u\'native\': \'\xd1\x81\xd1\x80\xd0\xbf\xd1\x81\xd0\xba\xd0\xb8\',\n u\'name\': \'Serbian\',\n u\'flag\': u\'/++resource++country-flags/cs.gif\',\n@@ -562,6 +565,23 @@ class MetadataLanguageAvailability(LanguageAvailability):\n },\n }\n \n+# Character sets are a thing now.\n+# See https://github.com/collective/plone.app.locales/issues/326\n+# At the moment only for Serbian.\n+_zope_i18n_allowed_languages = os.environ.get("zope_i18n_allowed_languages", "")\n+if \'sr@Latn\' in _zope_i18n_allowed_languages:\n+ _languagelist[u\'sr\'] = {\n+ u\'native\': \'Srpski\',\n+ u\'name\': \'Serbian (Latin)\',\n+ u\'flag\': u\'/++resource++country-flags/cs.gif\',\n+ }\n+elif \'sr@Cyrl\' in _zope_i18n_allowed_languages:\n+ _languagelist[u\'sr\'] = {\n+ u\'native\': \'\xd1\x81\xd1\x80\xd0\xbf\xd1\x81\xd0\xba\xd0\xb8\',\n+ u\'name\': \'Serbian (Cyrillic)\',\n+ u\'flag\': u\'/++resource++country-flags/cs.gif\',\n+ }\n+\n # convert the utf-8 encoded values to unicode\n for code in _languagelist:\n value = _languagelist[code]\n'
b"diff --git a/news/25.bugfix b/news/25.bugfix\nnew file mode 100644\nindex 0000000..cdab54d\n--- /dev/null\n+++ b/news/25.bugfix\n@@ -0,0 +1,2 @@\n+Fix batch numbers computation\n+[frapell]\ndiff --git a/plone/formwidget/recurrence/browser/json_recurrence.py b/plone/formwidget/recurrence/browser/json_recurrence.py\nindex cd2a79c..bd2ce30 100644\n--- a/plone/formwidget/recurrence/browser/json_recurrence.py\n+++ b/plone/formwidget/recurrence/browser/json_recurrence.py\n@@ -177,14 +177,14 @@ def json_string(self):\n cur_batch = cur_batch - first_batch\n # correct number of occurrences in current batch\n (cur_batch_start, cur_batch_end) = batches[cur_batch]\n- if cur_batch_end > len(occurrences):\n- batches[cur_batch] = (cur_batch_start, len(occurrences))\n+ if cur_batch_end > num_occurrences:\n+ batches[cur_batch] = (cur_batch_start, num_occurrences)\n \n batch_data = {'start': start,\n 'end': num_occurrences,\n 'batch_size': batch_size,\n 'batches': batches,\n- 'currentBatch': cur_batch - first_batch,\n+ 'currentBatch': cur_batch,\n }\n \n result = {'occurrences': occurrences, 'batch': batch_data}\n"

Repository: plone.i18n
Repository: plone.formwidget.recurrence


Branch: refs/heads/4.x
Date: 2021-10-14T12:40:41+02:00
Branch: refs/heads/master
Date: 2021-10-14T12:42:39+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: https://github.com/plone/plone.i18n/commit/8cbc7212955de32f7b14dbdfca4608c9855c8b6c
Commit: https://github.com/plone/plone.formwidget.recurrence/commit/276130072daf94f078cd2a1d338cde79ee947c3e

Merge pull request #37 from plone/maurits/serbian-4x
Merge pull request #27 from plone/frapell-batch-compute-master

Support Cyrillic and Latin character sets for Serbian. [4.x]
Fix batch numbers computation (Master)

Files changed:
A news/326.feature
M plone/i18n/locales/languages.py
A news/25.bugfix
M plone/formwidget/recurrence/browser/json_recurrence.py

b'diff --git a/news/326.feature b/news/326.feature\nnew file mode 100644\nindex 0000000..784a46f\n--- /dev/null\n+++ b/news/326.feature\n@@ -0,0 +1,3 @@\n+Support Cyrillic and Latin character sets for Serbian.\n+See `locales issue 326 <https://github.com/collective/plone.app.locales/issues/326>`_.\n+[maurits, fredvd]\ndiff --git a/plone/i18n/locales/languages.py b/plone/i18n/locales/languages.py\nindex 0ffec69..69a06a5 100644\n--- a/plone/i18n/locales/languages.py\n+++ b/plone/i18n/locales/languages.py\n@@ -4,6 +4,7 @@\n from plone.i18n.locales.interfaces import IMetadataLanguageAvailability\n from zope.interface import implementer\n \n+import os\n import six\n \n \n@@ -469,6 +470,8 @@ class MetadataLanguageAvailability(LanguageAvailability):\n u\'flag\': u\'/++resource++country-flags/al.gif\',\n },\n u\'sr\': {\n+ # Note: we support two character sets for this language.\n+ # See zope_i18n_allowed_languages below.\n u\'native\': \'\xd1\x81\xd1\x80\xd0\xbf\xd1\x81\xd0\xba\xd0\xb8\',\n u\'name\': \'Serbian\',\n u\'flag\': u\'/++resource++country-flags/cs.gif\',\n@@ -562,6 +565,23 @@ class MetadataLanguageAvailability(LanguageAvailability):\n },\n }\n \n+# Character sets are a thing now.\n+# See https://github.com/collective/plone.app.locales/issues/326\n+# At the moment only for Serbian.\n+_zope_i18n_allowed_languages = os.environ.get("zope_i18n_allowed_languages", "")\n+if \'sr@Latn\' in _zope_i18n_allowed_languages:\n+ _languagelist[u\'sr\'] = {\n+ u\'native\': \'Srpski\',\n+ u\'name\': \'Serbian (Latin)\',\n+ u\'flag\': u\'/++resource++country-flags/cs.gif\',\n+ }\n+elif \'sr@Cyrl\' in _zope_i18n_allowed_languages:\n+ _languagelist[u\'sr\'] = {\n+ u\'native\': \'\xd1\x81\xd1\x80\xd0\xbf\xd1\x81\xd0\xba\xd0\xb8\',\n+ u\'name\': \'Serbian (Cyrillic)\',\n+ u\'flag\': u\'/++resource++country-flags/cs.gif\',\n+ }\n+\n # convert the utf-8 encoded values to unicode\n for code in _languagelist:\n value = _languagelist[code]\n'
b"diff --git a/news/25.bugfix b/news/25.bugfix\nnew file mode 100644\nindex 0000000..cdab54d\n--- /dev/null\n+++ b/news/25.bugfix\n@@ -0,0 +1,2 @@\n+Fix batch numbers computation\n+[frapell]\ndiff --git a/plone/formwidget/recurrence/browser/json_recurrence.py b/plone/formwidget/recurrence/browser/json_recurrence.py\nindex cd2a79c..bd2ce30 100644\n--- a/plone/formwidget/recurrence/browser/json_recurrence.py\n+++ b/plone/formwidget/recurrence/browser/json_recurrence.py\n@@ -177,14 +177,14 @@ def json_string(self):\n cur_batch = cur_batch - first_batch\n # correct number of occurrences in current batch\n (cur_batch_start, cur_batch_end) = batches[cur_batch]\n- if cur_batch_end > len(occurrences):\n- batches[cur_batch] = (cur_batch_start, len(occurrences))\n+ if cur_batch_end > num_occurrences:\n+ batches[cur_batch] = (cur_batch_start, num_occurrences)\n \n batch_data = {'start': start,\n 'end': num_occurrences,\n 'batch_size': batch_size,\n 'batches': batches,\n- 'currentBatch': cur_batch - first_batch,\n+ 'currentBatch': cur_batch,\n }\n \n result = {'occurrences': occurrences, 'batch': batch_data}\n"

0 comments on commit 9ea13c6

Please sign in to comment.