ModLib icon indicating copy to clipboard operation
ModLib copied to clipboard

Allow settings localization

Open SaulHE opened this issue 5 years ago • 3 comments

Hi, Mipen.

I have been using you Modlib for my mod GrowUpAndWork.

And after I reference your lib as a required mod and as an external lib. It's very handy..

However, I encounter a problem.

Let's say I have a demand for localize it for some other language users.

Well the attributes of setting class attribute could not be easily changed in runtime.

(The SettingProperty.displayName and Hint field).

Could you maybe provide a way to change them in the future. I would like to detect the use's game language and change them accordingly.

Thanks!

SaulHE avatar Apr 19 '20 04:04 SaulHE

I have also had this request.

brandonm4 avatar Apr 19 '20 21:04 brandonm4

I would recommend changing the issue title to something more descriptive. Maybe something like: Allow settings localization

This is partly a duplicate of #22, which has a more descriptive issue title already.

MLNW avatar Apr 21 '20 09:04 MLNW

Could you do something as simple as this: SettingPropertyAttribute.cs

public SettingPropertyAttribute(string displayName, float minValue, float maxValue, float editableMinValue, float editableMaxValue, string hintText = "") { DisplayName = new TextObject(displayName).ToString(); MinValue = minValue; MaxValue = maxValue; EditableMinValue = editableMinValue; EditableMaxValue = editableMaxValue; HintText = new TextObject(hintText).ToString(); }

This would let us pass in descriptions like {=abc123}PropertyName and it should run through the localization process. Although we may have to put our xml files in the ModLib/ModuleData/Languages folder for it to find them (would need to test). If that is the case you would also need to run LocalizedTextManager.LoadLocalizationXmls(); in your SubModule OnLoad event as well if you're not already.

brandonm4 avatar Apr 27 '20 11:04 brandonm4