Skip to content

Commit

Permalink
Set default locale
Browse files Browse the repository at this point in the history
  • Loading branch information
bakeable committed May 30, 2024
1 parent 8cf68b2 commit b776720
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions akeneo_connector/akeneo_units.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
import locale

DefaultLocale = "nl_NL"
AkeneoUnitToSuffixDefault = {
'KILOGRAM': 'kg',
'GRAM': 'g',
'MILLIGRAM': 'mg',
'MICROGRAM': 'µg',
'TON': 't',
'POUND': 'lb',
'OUNCE': 'oz',
'MILLIMETER': 'mm',
'CENTIMETER': 'cm',
'METER': 'm',
'KILOMETER': 'km',
'INCH': 'in',
'FOOT': 'ft',
'YARD': 'yd',
'PIECE': 'pc',
'DOZEN': 'dz',
'MILLILITER': 'ml',
'CENTILITER': 'cl',
'LITER': 'l',
'GALLON': 'gal',
'BOX': 'box',
'PACK': 'pack',
'BOTTLE': 'bottle',
}
AkeneoUnitToSuffixByLocale = {
"en_US": AkeneoUnitToSuffixDefault,
"en_US": {
'KILOGRAM': 'kg',
'GRAM': 'g',
'MILLIGRAM': 'mg',
'MICROGRAM': 'µg',
'TON': 't',
'POUND': 'lb',
'OUNCE': 'oz',
'MILLIMETER': 'mm',
'CENTIMETER': 'cm',
'METER': 'm',
'KILOMETER': 'km',
'INCH': 'in',
'FOOT': 'ft',
'YARD': 'yd',
'PIECE': 'pc',
'DOZEN': 'dz',
'MILLILITER': 'ml',
'CENTILITER': 'cl',
'LITER': 'l',
'GALLON': 'gal',
'BOX': 'box',
'PACK': 'pack',
'BOTTLE': 'bottle',
},
"nl_NL": {
'KILOGRAM': 'kg',
'GRAM': 'g',
Expand Down Expand Up @@ -79,6 +78,7 @@
'BOTTLE': 'Flasche',
},
}
AkeneoUnitToSuffixDefault = AkeneoUnitToSuffixByLocale[DefaultLocale]
AkeneoUnitRounding = {
'KILOGRAM': 2,
'GRAM': 0,
Expand Down Expand Up @@ -115,6 +115,9 @@ def format_value(value: str | dict, locale_name: str | None = None) -> str:
"""
Format the value of an attribute.
"""
if locale_name is None:
locale_name = DefaultLocale

if value is None:
return "N/A"

Expand Down

0 comments on commit b776720

Please sign in to comment.