@rotki/ui-library 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -102,6 +102,68 @@ import { RuiIcon } from '@rotki/ui-library';
102
102
  </template>
103
103
  ```
104
104
 
105
+ ### Setting up internationalization (i18n)
106
+
107
+ The UI library supports internationalization through the `createRuiI8nPlugin` function. This allows you to provide translations for UI components.
108
+
109
+ #### Setting up the i18n plugin
110
+
111
+ First, you need to set up your Vue i18n instance and then connect it to the UI library:
112
+
113
+ ```typescript
114
+ import { createRui, createRuiI8nPlugin } from '@rotki/ui-library';
115
+ import { createApp } from 'vue';
116
+ import { createI18n } from 'vue-i18n';
117
+
118
+ // Create your i18n instance
119
+ const i18n = createI18n({
120
+ legacy: false, // You must set `false`, to use Composition API
121
+ locale: 'en',
122
+ messages: {
123
+ en: {
124
+ // Your app translations
125
+ // UI library translations (see below)
126
+ rui: {
127
+ date_time_picker: {
128
+ date_after_max: 'Date cannot be after {date}',
129
+ date_before_min: 'Date cannot be before {date}',
130
+ date_in_future: 'The selected date cannot be in the future',
131
+ },
132
+ },
133
+ },
134
+ // Other languages...
135
+ },
136
+ });
137
+
138
+ const app = createApp(App);
139
+
140
+ // Create and use the Rotki UI plugin
141
+ const RuiPlugin = createRui();
142
+ app.use(RuiPlugin);
143
+
144
+ // Create and use the Rotki UI i18n plugin
145
+ const RuiI18nPlugin = createRuiI8nPlugin(i18n);
146
+ app.use(RuiI18nPlugin);
147
+
148
+ app.use(i18n);
149
+ app.mount('#app');
150
+ ```
151
+
152
+ #### Available translation keys
153
+
154
+ The UI library uses the following translation keys:
155
+
156
+ ```typescript
157
+ // These are defined in src/i18n/keys.ts
158
+ export const RUI_I18N_KEYS = {
159
+ dateTimePicker: {
160
+ dateAfterMax: 'rui.date_time_picker.date_after_max',
161
+ dateBeforeMin: 'rui.date_time_picker.date_before_min',
162
+ dateInFuture: 'rui.date_time_picker.date_in_future',
163
+ },
164
+ } as const;
165
+ ```
166
+
105
167
  ### Use @rotki/ui-library tailwindcss theme
106
168
 
107
169
  You can extend @rotki/ui-library tailwind theme configuration by adding these to your tailwind config. It will provide you the classes for the colors, typography, and shadow.
@@ -4,7 +4,7 @@ type DateTimeModelType = 'date' | 'epoch-ms' | 'epoch';
4
4
  type ModelValueType<T extends DateTimeModelType> = T extends 'date' ? Date | undefined : T extends 'epoch-ms' ? number | undefined : T extends 'epoch' ? number | undefined : Date | number | undefined;
5
5
  export interface RuiDateTimePickerProps {
6
6
  minDate?: Date | number;
7
- maxDate?: Date | number;
7
+ maxDate?: Date | number | 'now';
8
8
  format?: DateFormat;
9
9
  type?: DateTimeModelType;
10
10
  accuracy?: TimeAccuracy;
@@ -30,7 +30,7 @@ declare const props: Readonly<{}> & {
30
30
  readonly label: string;
31
31
  readonly variant: "default" | "outlined" | "filled";
32
32
  readonly hint: string | undefined;
33
- readonly maxDate: number | Date | undefined;
33
+ readonly maxDate: number | Date | "now" | undefined;
34
34
  readonly minDate: number | Date | undefined;
35
35
  readonly format: DateFormat;
36
36
  readonly accuracy: TimeAccuracy;
@@ -64,7 +64,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps,
64
64
  hint: string;
65
65
  hideDetails: boolean;
66
66
  dense: boolean;
67
- maxDate: Date | number;
67
+ maxDate: Date | number | "now";
68
68
  minDate: Date | number;
69
69
  allowEmpty: boolean;
70
70
  accuracy: TimeAccuracy;