Skip to content

Commit

Permalink
Add localization to units, denote volume vs. weight
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsage committed Jan 27, 2023
1 parent 5c1f17f commit 0dc833b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
Binary file modified FS22_ProductionInspector.zip
Binary file not shown.
Binary file modified FS22_ProductionInspector_update.zip
Binary file not shown.
37 changes: 22 additions & 15 deletions src/lib/fs22FSGUnitConvert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ function FS22FSGUnits:new(logger)
}

self.units = {
[self.unitsToIndex.LITER] = { precision = 0, isWeight = false, text = "l", factor = 1 },
[self.unitsToIndex.BUSHEL] = { precision = 2, isWeight = false, text = "bu", factor = 0.028378 },
[self.unitsToIndex.C_METER] = { precision = 3, isWeight = false, text = "", factor = 0.001 },
[self.unitsToIndex.C_FOOT] = { precision = 2, isWeight = false, text = "ft³", factor = 0.035315 },
[self.unitsToIndex.C_YARD] = { precision = 2, isWeight = false, text = "yd³", factor = 0.001308},
[self.unitsToIndex.KG] = { precision = 0, isWeight = true, text = "kg", factor = 1 },
[self.unitsToIndex.OZ] = { precision = 0, isWeight = true, text = "oz", factor = 35.27396 },
[self.unitsToIndex.LBS] = { precision = 0, isWeight = true, text = "lbs", factor = 2.204623 },
[self.unitsToIndex.CWT] = { precision = 2, isWeight = true, text = "cwt", factor = 0.022046 },
[self.unitsToIndex.MT] = { precision = 3, isWeight = true, text = "mt", factor = 0.001 },
[self.unitsToIndex.T] = { precision = 3, isWeight = true, text = "t", factor = 0.0011023 },
[self.unitsToIndex.F_OZ] = { precision = 0, isWeight = false, text = "fl.oz", factor = 33.814023 },
[self.unitsToIndex.GAL] = { precision = 2, isWeight = false, text = "gal", factor = 0.264172},
[self.unitsToIndex.LITER] = { precision = 0, isWeight = false, text = "unit_literShort", factor = 1 },
[self.unitsToIndex.BUSHEL] = { precision = 2, isWeight = false, text = "unit_bushelsShort", factor = 0.028378 },
[self.unitsToIndex.C_METER] = { precision = 3, isWeight = false, text = "unit_cubicShort", factor = 0.001 },
[self.unitsToIndex.C_FOOT] = { precision = 2, isWeight = false, text = "unit_fsgUnitConvert_cubicFoot", factor = 0.035315 },
[self.unitsToIndex.C_YARD] = { precision = 2, isWeight = false, text = "unit_fsgUnitConvert_cubicYard", factor = 0.001308},
[self.unitsToIndex.KG] = { precision = 0, isWeight = true, text = "unit_kg", factor = 1 },
[self.unitsToIndex.OZ] = { precision = 0, isWeight = true, text = "unit_fsgUnitConvert_ounce", factor = 35.27396 },
[self.unitsToIndex.LBS] = { precision = 0, isWeight = true, text = "unit_fsgUnitConvert_poundWeight", factor = 2.204623 },
[self.unitsToIndex.CWT] = { precision = 2, isWeight = true, text = "unit_fsgUnitConvert_hundredWeight", factor = 0.022046 },
[self.unitsToIndex.MT] = { precision = 3, isWeight = true, text = "unit_tonsShort", factor = 0.001 },
[self.unitsToIndex.T] = { precision = 3, isWeight = true, text = "unit_fsgUnitConvert_imperialTon", factor = 0.0011023 },
[self.unitsToIndex.F_OZ] = { precision = 0, isWeight = false, text = "unit_fsgUnitConvert_fluidOunce", factor = 33.814023 },
[self.unitsToIndex.GAL] = { precision = 2, isWeight = false, text = "unit_fsgUnitConvert_fluidGallon", factor = 0.264172},
}

self.unit_select = {
Expand Down Expand Up @@ -116,7 +116,14 @@ function FS22FSGUnits:getSettingsTexts(unitType)
end

for _, typeIdx in ipairs(self.unit_select[unitType]) do
table.insert(settingsTable, self.units[typeIdx].text)
local thisUnitMeasure = g_i18n:getText('unit_fsgUnitConvert_Volume')

if self.units[typeIdx].isWeight then
thisUnitMeasure = g_i18n:getText('unit_fsgUnitConvert_Weight')
end

local thisUnit = thisUnitMeasure .. " | " .. g_i18n:getText(self.units[typeIdx].text)
table.insert(settingsTable, thisUnit)
end

return settingsTable
Expand Down Expand Up @@ -174,7 +181,7 @@ function FS22FSGUnits:scaleFillTypeLevel(fillTypeIdx, fillLevel, unitIdxSolid, u
local convertedFillLevel = MathUtil.round(returnFillLevel * unitData.factor, unitData.precision)

if showTheUnit then
return tostring(convertedFillLevel) .. " " .. unitData.text
return tostring(convertedFillLevel) .. " " .. g_i18n:getText(unitData.text)
else
return tostring(convertedFillLevel)
end
Expand Down
10 changes: 10 additions & 0 deletions src/translations/translation_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,15 @@
<text name="toolTip_productionInspector_SolidUnit" text="Verwenden Sie diese Maßeinheit, um feste Produkte anzuzeigen" />
<text name="setting_productionInspector_LiquidUnit" text="Maßeinheit: Flüssigkeiten" />
<text name="toolTip_productionInspector_LiquidUnit" text="Verwenden Sie diese Maßeinheit, um flüssige Produkte anzuzeigen" />
<text name="unit_fsgUnitConvert_Volume" text="Volumen Einheit" />
<text name="unit_fsgUnitConvert_Weight" text="Gewicht Einheit" />
<text name="unit_fsgUnitConvert_cubicFoot" text="ft³" />
<text name="unit_fsgUnitConvert_cubicYard" text="yd³" />
<text name="unit_fsgUnitConvert_ounce" text="oz" />
<text name="unit_fsgUnitConvert_poundWeight" text="lbs" />
<text name="unit_fsgUnitConvert_hundredWeight" text="cwt" />
<text name="unit_fsgUnitConvert_imperialTon" text="tn" />
<text name="unit_fsgUnitConvert_fluidOunce" text="fl.oz" />
<text name="unit_fsgUnitConvert_fluidGallon" text="gal" />
</texts>
</l10n>
10 changes: 10 additions & 0 deletions src/translations/translation_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,15 @@
<text name="toolTip_productionInspector_SolidUnit" text="Use this unit of measure to display solid products" />
<text name="setting_productionInspector_LiquidUnit" text="Unit of measure: Liquids" />
<text name="toolTip_productionInspector_LiquidUnit" text="Use this unit of measure to display liquid products" />
<text name="unit_fsgUnitConvert_Volume" text="Volume Unit" />
<text name="unit_fsgUnitConvert_Weight" text="Weight Unit" />
<text name="unit_fsgUnitConvert_cubicFoot" text="ft³" />
<text name="unit_fsgUnitConvert_cubicYard" text="yd³" />
<text name="unit_fsgUnitConvert_ounce" text="oz" />
<text name="unit_fsgUnitConvert_poundWeight" text="lbs" />
<text name="unit_fsgUnitConvert_hundredWeight" text="cwt" />
<text name="unit_fsgUnitConvert_imperialTon" text="tn" />
<text name="unit_fsgUnitConvert_fluidOunce" text="fl.oz" />
<text name="unit_fsgUnitConvert_fluidGallon" text="gal" />
</texts>
</l10n>
10 changes: 10 additions & 0 deletions src/translations/translation_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,15 @@
<text name="toolTip_productionInspector_SolidUnit" text="Используйте эту единицу измерения для отображения твердых продуктов" />
<text name="setting_productionInspector_LiquidUnit" text="Единица измерения: Жидкости" />
<text name="toolTip_productionInspector_LiquidUnit" text="Используйте эту единицу измерения для отображения жидких продуктов" />
<text name="unit_fsgUnitConvert_Volume" text="Ед. измерения объёма" />
<text name="unit_fsgUnitConvert_Weight" text="Ед. измерения массы" />
<text name="unit_fsgUnitConvert_cubicFoot" text="ft³" />
<text name="unit_fsgUnitConvert_cubicYard" text="yd³" />
<text name="unit_fsgUnitConvert_ounce" text="oz" />
<text name="unit_fsgUnitConvert_poundWeight" text="lbs" />
<text name="unit_fsgUnitConvert_hundredWeight" text="cwt" />
<text name="unit_fsgUnitConvert_imperialTon" text="tn" />
<text name="unit_fsgUnitConvert_fluidOunce" text="fl.oz" />
<text name="unit_fsgUnitConvert_fluidGallon" text="gal" />
</texts>
</l10n>

0 comments on commit 0dc833b

Please sign in to comment.