-
-
Notifications
You must be signed in to change notification settings - Fork 119
Localization with Custom Locales
Most of example that you will find across this library were made with ngx-translate
(dynamic translation) support. However a few users of the lib only use 1 locale (English or any other locale). Since not all users requires multiple translations, as of version 2.13.0
, it is now possible to use Angular-Slickgrid
without ngx-translate
. What is the difference with/without ngx-translate
? Not much, the only difference is that ngx-translate
is now an optional dependency (thanks to Angular @Optional Dependency, via @Optional() TranslateService
), so if you don't provide ngx-translate
, it will simply try to use Custom Locales, you can provide your own locales (see instruction below), or if none are provided it will use English locales by default.
There are 2 ways of using and defining Custom Locales, see below on how to achieve that.
English is the default, if that is the locale you want to use then there's nothing to do, move along...
To use any other Locales, you will need to create a TypeScript file of all the Locale Texts required for the library to work properly (if you forget to define a locale text, it will simply show up in English). For example, if we define a French Locale, it would look like this (for the complete list of required field take a look at the default English Locale)
// localeFrench.ts or fr.ts
export const localeFrench = {
// texte requis
TEXT_ALL_SELECTED: 'Tout sélectionnés',
TEXT_CANCEL: 'Annuler',
TEXT_CLEAR_ALL_FILTERS: 'Supprimer tous les filtres',
TEXT_CLEAR_ALL_SORTING: 'Supprimer tous les tris',
// ... the rest of the text
This will literally configure Custom Locales for the entire project, so if you want to do it once, that is the place to do it.
// app.module.ts
@NgModule({
imports: [
AngularSlickgridModule.forRoot({
// add any Global Grid Options/Config you might want
// Provide a custom locales set
locales: localeFrench,
})
]
});
You can alternatively provide Custom Locales through any grid declaration through the locales
Grid Options (it's the same as the global one, except that it's per grid)
import { localeFrench } from 'locales/fr';
export class MyGridComponent {
prepareGrid() {
this.columnDefinitions = [ /* ... */ ];
this.gridOptions = {
enableAutoResize: true,
// provide Custom Locale to this grid only
locales: localeFrench
};
}
}
There's nothing else to do, just use the library without defining or providing TranslateService and you're good to go. Read through the Wiki of the HOWTO for basic grid samples.
Contents
- Angular-Slickgrid Wiki
- Installation
- Styling
- Interfaces/Models
- Testing Patterns
- Column Functionalities
- Global Grid Options
- Localization
- Events
- Grid Functionalities
- Auto-Resize / Resizer Service
- Resize by Cell Content
- Composite Editor
- Context Menu
- Custom Tooltip
- Add/Delete/Update or Highlight item
- Dynamically Change Row CSS Classes
- Excel Copy Buffer
- Export to Excel
- Export to File (CSV/Txt)
- Grid State & Presets
- Grouping & Aggregators
- Row Detail
- SlickGrid Controls
- SlickGrid Plugins
- Pinning (frozen) of Columns/Rows
- Tree Data Grid
- SlickGrid & DataView objects
- Addons (controls/plugins)
- Backend Services