Setup
- Import BGLocalization package
- Create your own database ( more info). Choose Resources or StreamingAssets loader for your database.
- Enable localization addon
- Go to Database->Localization and add your locales. Locale name - letters only, 8 chars maximum. Note, locales is just a regular table, so you can add your own fields, like native spelling, flag icons etc.
Setup single value table
Single value table is easy to use, but can have only one field.
- Go to Configuration and create a table (type of the table is LocalizationSingleValue), choose the type of data to be stored.
- Go to Database->"Your created table", add some rows. You can edit values for all locales here. Also, you can use machine translation (Learn more about auto-translation here)
Setup embedded fields
Embedded fields allow you to embed localization fields into normal rows along with other fields and require more actions.
- Go to Configuration and create a table for your locale data (type of the table is Localization), choose the type of data to be stored.
- Create a normal table (row)
- Add a localized field to this table. You will need to choose a related table (created at step 1) here
- Go to Database->"Your created table", add some rows. You can edit localized values here (current locale will be used)
- Another option - is to choose "localization" table and edit values for all locales at once. You can use Auto-translation here
- Learn more about auto-translation here
- Once your data is ready, you can localize your Components (any field or property). For more details, please read the following section
How to localize fields/properties
More details about data binding can be found here
If you need to localize single field/property using single cell value from database, use BGDataBinderFieldGo component (or legacy BGLocalizationGo)
If you need to use text template, use BGDataBinderTemplateGo component (or use a graph binder ↓ )
If you need to calculate a final value to inject - use a graph-based binder
If you want to localize multiple fields/properties from multiple GameObjects with single component, use BGDataBinderBatchGo component
Localization add-on adds the following features to data binding:
- For single value localization, it adds special $locale field, if your meta has localizationSingleValue type
- For templates, you can also use $locale as field name, if your meta has localizationSingleValue type
- For graph binder it adds get/set locale units and special "GetLocalizeValue" for each single value localization table
How to change locale
// method #1
BGAddonLocalization.DefaultRepoCurrentLocale = "en"; // replace en with your locale name
// method #2
var addon = BGRepo.I.Addons.Get<BGAddonLocalization>();
addon.CurrentLocale = "en"; // replace en with your locale name
Example project
Example project is available for download here