How to add, override, and use different resource strings to customize the Order Website.
Overview
By convention, Atomia Order Website (Atomia Store) uses the App_GlobalResources\Common.resx file and derived theme files and translations for all changeable resource strings and translations except some validation messages, which are located in CustomerValidation.resx.
File Structure
An example file structure with themes and translations:
App_GlobalResources/
MyTheme/
MyThemeCommon.resx
MyThemeCommon.de-DE.resx
MyThemeCustomerValidation.resx
MyThemeCustomerValidation.de-DE.resx
Common.resx
Common.de-DE.resx
CustomerValidation.resx
CustomerValidation.de-DE.resx
The example above has the default English resource strings in the resx files without language code, and default German localization in the *.de-DE.resx files.
The theme resource files must be located in a directory with the same name as the theme, and must also be prefixed with that name, MyTheme in this example.
Adding or Overriding Default Resource Strings
When you start a new theme, empty resource files are added to the theme for all default (English) and localized resxfiles that are available in the Default theme. You can use these files to add your own resource strings or override resource strings from the Default theme.
Special Resource String
Some resource strings in Common.resx and derived files have a specific Name or Value format. These are annotated with comments in the Common.resx file in the Default theme.
E.g. language names are located via Name keys on the form <LanguageTag>_name and <LanguageTag>_shortname: EN_name – English, EN_shortname – EN, FR_name – French, FR_shortname – FR etc.
Using Resources in Views
The recommended way of using resources from Common.resx in views is to use the @Html.CommonResource, @Html.CommonResourceRaw and @Html.CommonResourceJs HTML-helpers, which will output escaped, unescaped and JavaScript expression ready strings respectively. This will automatically locate the string Name in the correct resxfile, Default or from the theme. The HTML-helpers are defined in Atomia.Store.WebBase.HtmlHelpers.CommonResourcesHelper and are implicitly imported in all views by default.
Example usage:
@Html.CommonResource("AccountTitle")
JavaScript objects or JSON available via the Atomia namespace should also have any relevant properties already translated before being sent from or generated by the server, e.g. product names and descriptions.
Using Resources in .NET Code Via IResourceProvider
The recommended way of using resources in backend .NET code is to use the Atomia.Store.Core.IResourceProvider. It has a default implementation Atomia.Store.WebBase.Adapters.ResourceProvider that fetches resources from Common.resx and related localization and theme files.