diff --git a/rendercv/data_models.py b/rendercv/data_models.py index 45ff50c..8a9f3f0 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -38,29 +38,9 @@ from .themes.engineeringresumes import EngineeringresumesThemeOptions # Disable Pydantic warnings: warnings.filterwarnings("ignore") -locale_catalog = { - "month": "month", - "months": "months", - "year": "year", - "years": "years", - "present": "present", - "to": "to", - # Month abbreviations are taken from https://web.library.yale.edu/cataloging/months: - "abbreviations_for_months": [ - "Jan.", - "Feb.", - "Mar.", - "Apr.", - "May", - "June", - "July", - "Aug.", - "Sept.", - "Oct.", - "Nov.", - "Dec.", - ], -} + +# The dictionary below will be overwritten by LocaleCatalog class. +locale_catalog = {} def get_date_object(date: str | int) -> Date: @@ -1102,27 +1082,32 @@ class LocaleCatalog(RenderCVBaseModel): validate_default=True, # To initialize the locale catalog with the default values ) to: Optional[str] = pydantic.Field( - default="to", + default="--", title='Translation of "To"', - description='Translation of the word "to" in the locale.', + description=( + "The word or character used to indicate a range in the locale (e.g.," + ' "2020 - 2021").' + ), validate_default=True, # To initialize the locale catalog with the default values ) abbreviations_for_months: Optional[ Annotated[list[str], at.Len(min_length=12, max_length=12)] ] = pydantic.Field( + # Month abbreviations are taken from + # https://web.library.yale.edu/cataloging/months: default=[ - "Jan.", - "Feb.", - "Mar.", - "Apr.", + "Jan", + "Feb", + "Mar", + "Apr", "May", "June", "July", - "Aug.", - "Sept.", - "Oct.", - "Nov.", - "Dec.", + "Aug", + "Sept", + "Oct", + "Nov", + "Dec", ], title="Abbreviations of Months", description="Abbreviations of the months in the locale.", @@ -1140,6 +1125,7 @@ class LocaleCatalog(RenderCVBaseModel): return value +LocaleCatalog() # Initialize the locale catalog with the default values # ====================================================================================== # ====================================================================================== diff --git a/tests/test_data_models.py b/tests/test_data_models.py index 1f1c89e..9da454a 100644 --- a/tests/test_data_models.py +++ b/tests/test_data_models.py @@ -42,18 +42,18 @@ def test_get_date_object(date, expected_date_object, expected_error): @pytest.mark.parametrize( "date, expected_date_string", [ - (Date(2020, 1, 1), "Jan. 2020"), - (Date(2020, 2, 1), "Feb. 2020"), - (Date(2020, 3, 1), "Mar. 2020"), - (Date(2020, 4, 1), "Apr. 2020"), + (Date(2020, 1, 1), "Jan 2020"), + (Date(2020, 2, 1), "Feb 2020"), + (Date(2020, 3, 1), "Mar 2020"), + (Date(2020, 4, 1), "Apr 2020"), (Date(2020, 5, 1), "May 2020"), (Date(2020, 6, 1), "June 2020"), (Date(2020, 7, 1), "July 2020"), - (Date(2020, 8, 1), "Aug. 2020"), - (Date(2020, 9, 1), "Sept. 2020"), - (Date(2020, 10, 1), "Oct. 2020"), - (Date(2020, 11, 1), "Nov. 2020"), - (Date(2020, 12, 1), "Dec. 2020"), + (Date(2020, 8, 1), "Aug 2020"), + (Date(2020, 9, 1), "Sept 2020"), + (Date(2020, 10, 1), "Oct 2020"), + (Date(2020, 11, 1), "Nov 2020"), + (Date(2020, 12, 1), "Dec 2020"), ], ) def test_format_date(date, expected_date_string): @@ -225,71 +225,71 @@ def test_generate_json_schema_file(tmp_path): "2020-01-01", "2021-01-01", None, - "Jan. 2020 to Jan. 2021", - "2020 to 2021", + "Jan 2020 -- Jan 2021", + "2020 -- 2021", "1 year 1 month", ), ( Date(2020, 1, 1), Date(2021, 1, 1), None, - "Jan. 2020 to Jan. 2021", - "2020 to 2021", + "Jan 2020 -- Jan 2021", + "2020 -- 2021", "1 year 1 month", ), ( "2020-01", "2021-01", None, - "Jan. 2020 to Jan. 2021", - "2020 to 2021", + "Jan 2020 -- Jan 2021", + "2020 -- 2021", "1 year 1 month", ), ( "2020-01", "2021-01-01", None, - "Jan. 2020 to Jan. 2021", - "2020 to 2021", + "Jan 2020 -- Jan 2021", + "2020 -- 2021", "1 year 1 month", ), ( "2020-01-01", "2021-01", None, - "Jan. 2020 to Jan. 2021", - "2020 to 2021", + "Jan 2020 -- Jan 2021", + "2020 -- 2021", "1 year 1 month", ), ( "2020-01-01", None, None, - "Jan. 2020 to present", - "2020 to present", + "Jan 2020 -- present", + "2020 -- present", "4 years 1 month", ), ( "2020-02-01", "present", None, - "Feb. 2020 to present", - "2020 to present", + "Feb 2020 -- present", + "2020 -- present", "3 years 11 months", ), - ("2020-01-01", "2021-01-01", "2023-02-01", "Feb. 2023", "2023", ""), - ("2020", "2021", None, "2020 to 2021", "2020 to 2021", "1 year"), - ("2020", None, None, "2020 to present", "2020 to present", "4 years"), - ("2020-10-10", "2022", None, "Oct. 2020 to 2022", "2020 to 2022", "2 years"), + ("2020-01-01", "2021-01-01", "2023-02-01", "Feb 2023", "2023", ""), + ("2020", "2021", None, "2020 -- 2021", "2020 -- 2021", "1 year"), + ("2020", None, None, "2020 -- present", "2020 -- present", "4 years"), + ("2020-10-10", "2022", None, "Oct 2020 -- 2022", "2020 -- 2022", "2 years"), ( "2020-10-10", "2020-11-05", None, - "Oct. 2020 to Nov. 2020", - "2020 to 2020", + "Oct 2020 -- Nov 2020", + "2020 -- 2020", "1 month", ), - ("2022", "2023-10-10", None, "2022 to Oct. 2023", "2022 to 2023", "1 year"), + ("2022", "2023-10-10", None, "2022 -- Oct 2023", "2022 -- 2023", "1 year"), ( "2020-01-01", "present", @@ -322,12 +322,12 @@ def test_generate_json_schema_file(tmp_path): "My Custom Date", "", ), - (None, None, "2020-01-01", "Jan. 2020", "2020", ""), - (None, None, "2020-09", "Sept. 2020", "2020", ""), - (None, None, Date(2020, 1, 1), "Jan. 2020", "2020", ""), + (None, None, "2020-01-01", "Jan 2020", "2020", ""), + (None, None, "2020-09", "Sept 2020", "2020", ""), + (None, None, Date(2020, 1, 1), "Jan 2020", "2020", ""), (None, None, None, "", "", ""), - (None, "2020-01-01", None, "Jan. 2020", "2020", ""), - (None, "present", None, "Jan. 2024", "2024", ""), + (None, "2020-01-01", None, "Jan 2020", "2020", ""), + (None, "present", None, "Jan 2024", "2024", ""), ("2002", "2020", "2024", "2024", "2024", ""), ], ) @@ -350,8 +350,8 @@ def test_dates( @pytest.mark.parametrize( "date, expected_date_string", [ - ("2020-01-01", "Jan. 2020"), - ("2020-01", "Jan. 2020"), + ("2020-01-01", "Jan 2020"), + ("2020-01", "Jan 2020"), ("2020", "2020"), ], )