Skip to content

Commit

Permalink
Add support for Hebrew prefixes
Browse files Browse the repository at this point in the history
* Double the Vav if not already double
* Remove the leading He
* Prefix a maqaf for non-Hebrew words and numbers
  • Loading branch information
Nick-Hall committed Aug 20, 2023
1 parent b43810b commit 7703cb6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions gramps/plugins/lib/libnarrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ def _get_empty_endnote_numbers(obj):
return ""


def convert_prefix(word):
"""
Convert Hebrew grammar for prefixes
"""
if not word or len(word) < 2:
return word
if word[0] == "ו" and word[1] != "ו":
# Double the Vav if not already double
word = "ו" + word
if word[0] == "ה":
# Remove the leading He
word = word[1:]
if word[0] < "א" or word[0] > "ת":
# Prefix a maqaf for non-Hebrew words and numbers
word = "־" + word
return word


# avoid normal translation!
# enable deferred translations
# (these days this is done elsewhere as _T_ but it was done here first)
Expand Down Expand Up @@ -1781,6 +1799,10 @@ def get_born_string(self):
bdate_full = bdate_obj and bdate_obj.get_day_valid()
bdate_mod = bdate_obj and bdate_obj.get_modifier() != Date.MOD_NONE

if self._locale.locale_code() == "he":
bdate = convert_prefix(bdate)
bplace = convert_prefix(bplace)

value_map = {
"name": self.__first_name,
"male_name": self.__first_name,
Expand Down Expand Up @@ -1897,6 +1919,10 @@ def get_died_string(self, include_age=False):
age = 0
age_index = _AGE_INDEX_NO_AGE

if self._locale.locale_code() == "he":
ddate = convert_prefix(ddate)
dplace = convert_prefix(dplace)

value_map = {
"name": self.__first_name,
"unknown_gender_name": self.__first_name,
Expand Down Expand Up @@ -2014,6 +2040,10 @@ def get_buried_string(self):
else:
return text

if self._locale.locale_code() == "he":
bdate = convert_prefix(bdate)
bplace = convert_prefix(bplace)

value_map = {
"unknown_gender_name": self.__first_name,
"male_name": self.__first_name,
Expand Down Expand Up @@ -2127,6 +2157,10 @@ def get_baptised_string(self):
else:
return text

if self._locale.locale_code() == "he":
bdate = convert_prefix(bdate)
bplace = convert_prefix(bplace)

value_map = {
"unknown_gender_name": self.__first_name,
"male_name": self.__first_name,
Expand Down Expand Up @@ -2242,6 +2276,10 @@ def get_christened_string(self):
else:
return text

if self._locale.locale_code() == "he":
cdate = convert_prefix(cdate)
cplace = convert_prefix(cplace)

value_map = {
"unknown_gender_name": self.__first_name,
"male_name": self.__first_name,
Expand Down Expand Up @@ -2350,6 +2388,10 @@ def get_married_string(self, family, is_first=True, name_display=None):
place = _pd.display_event(self.__db, event, fmt=self._place_format)
relationship = family.get_relationship()

if self._locale.locale_code() == "he":
date = convert_prefix(date)
place = convert_prefix(place)

value_map = {
"spouse": spouse_name,
"endnotes": self.__get_endnote_numbers(event),
Expand Down

0 comments on commit 7703cb6

Please sign in to comment.