@colixsystems/widget-sdk 0.326.0 → 0.327.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.
@@ -0,0 +1,155 @@
1
+ // The words SDK components show when the author passes none, in the app's
2
+ // language (ctx.i18n.locale on both hosts). contract.js joins this table with
3
+ // the shared translation keys into the ONE table every component reads, so no
4
+ // component carries its own translation (CLAUDE.md §3).
5
+ //
6
+ // These texts are never seeded into a workspace's dictionary: several carry a
7
+ // `{count}` or `{label}` slot that machine translation at seeding would mangle.
8
+ // Languages follow the shared keys: English and a hand-written Swedish; every
9
+ // other language falls back to English.
10
+
11
+ /**
12
+ * Per key: the text in each shipped language, English always present. A text
13
+ * with a `{count}` slot is `{ one, other }`, picked by the language's plural rule.
14
+ */
15
+ export const COMPONENT_TEXTS = Object.freeze({
16
+ select_placeholder: { en: "Select", sv: "Välj" },
17
+ no_options: { en: "No options", sv: "Inga alternativ" },
18
+ done: { en: "Done", sv: "Klar" },
19
+ selected_count: {
20
+ en: { one: "{count} selected", other: "{count} selected" },
21
+ sv: { one: "{count} vald", other: "{count} valda" },
22
+ },
23
+ options_load_failed: { en: "Could not load the options", sv: "Det gick inte att läsa in alternativen" },
24
+ clear: { en: "Clear", sv: "Rensa" },
25
+ clear_search: { en: "Clear search", sv: "Rensa sökningen" },
26
+ unknown: { en: "Unknown", sv: "Okänd" },
27
+ dismiss: { en: "Dismiss", sv: "Stäng" },
28
+ select_date: { en: "Select date", sv: "Välj datum" },
29
+ select_time: { en: "Select time", sv: "Välj tid" },
30
+ select_date_time: { en: "Select date & time", sv: "Välj datum och tid" },
31
+
32
+ choose_file: { en: "Choose file", sv: "Välj fil" },
33
+ choose_files: { en: "Choose files", sv: "Välj filer" },
34
+ uploading: { en: "Uploading…", sv: "Laddar upp…" },
35
+ no_file_chosen: { en: "No file chosen", sv: "Ingen fil vald" },
36
+ no_files_chosen: { en: "No files chosen", sv: "Inga filer valda" },
37
+ file_type_rejected: { en: "That file type isn't accepted here.", sv: "Den filtypen tas inte emot här." },
38
+ single_file_kept: {
39
+ en: "Only one file can be added here, so the first was kept.",
40
+ sv: "Här går det bara att lägga till en fil, så den första behölls.",
41
+ },
42
+ drop_file: { en: "or drop a file here", sv: "eller släpp en fil här" },
43
+ drop_files: { en: "or drop files here", sv: "eller släpp filer här" },
44
+ file_choice_unavailable: { en: "Choosing files isn't available here.", sv: "Det går inte att välja filer här." },
45
+
46
+ filter_any: { en: "Any", sv: "Alla" },
47
+ filters: { en: "Filters", sv: "Filter" },
48
+ filters_active_count: {
49
+ en: { one: "{count} active", other: "{count} active" },
50
+ sv: { one: "{count} aktivt", other: "{count} aktiva" },
51
+ },
52
+ clear_all: { en: "Clear all", sv: "Rensa alla" },
53
+ apply: { en: "Apply", sv: "Använd" },
54
+ active_filters: { en: "Active filters", sv: "Aktiva filter" },
55
+ remove_named: { en: "Remove {label}", sv: "Ta bort {label}" },
56
+ sort: { en: "Sort", sv: "Sortera" },
57
+ sorted_ascending: { en: "sorted ascending", sv: "sorterad stigande" },
58
+ sorted_descending: { en: "sorted descending", sv: "sorterad fallande" },
59
+
60
+ move_item: { en: "Move {item}", sv: "Flytta {item}" },
61
+ move_hint: {
62
+ en: "Drag to move it, or open the move options. The arrow keys move it too.",
63
+ sv: "Dra för att flytta, eller öppna flyttalternativen. Piltangenterna flyttar också.",
64
+ },
65
+ move_up: { en: "Move up", sv: "Flytta upp" },
66
+ move_down: { en: "Move down", sv: "Flytta ned" },
67
+ move_to_top: { en: "Move to top", sv: "Flytta högst upp" },
68
+ move_to_bottom: { en: "Move to bottom", sv: "Flytta längst ned" },
69
+ move_to_column: { en: "Move to {column}", sv: "Flytta till {column}" },
70
+ moved: { en: "{item} moved to position {position} of {total}", sv: "{item} flyttades till plats {position} av {total}" },
71
+ moved_to_column: { en: "{item} moved to {column}, position {position}", sv: "{item} flyttades till {column}, plats {position}" },
72
+
73
+ choose_emoji: { en: "Choose an emoji", sv: "Välj en emoji" },
74
+ close_emoji_picker: { en: "Close the emoji picker", sv: "Stäng emojiväljaren" },
75
+ search_emoji: { en: "Search emoji", sv: "Sök emoji" },
76
+ no_emoji_found: { en: "No emoji found", sv: "Inga emojier hittades" },
77
+ emoji_recent: { en: "Recent", sv: "Senaste" },
78
+ emoji_smileys: { en: "Smileys & Emotion", sv: "Smileys och känslor" },
79
+ emoji_people: { en: "People & Body", sv: "Människor och kropp" },
80
+ emoji_animals: { en: "Animals & Nature", sv: "Djur och natur" },
81
+ emoji_food: { en: "Food & Drink", sv: "Mat och dryck" },
82
+ emoji_activity: { en: "Activity", sv: "Aktiviteter" },
83
+ emoji_travel: { en: "Travel & Places", sv: "Resor och platser" },
84
+ emoji_objects: { en: "Objects", sv: "Föremål" },
85
+ emoji_symbols: { en: "Symbols", sv: "Symboler" },
86
+ emoji_flags: { en: "Flags", sv: "Flaggor" },
87
+
88
+ format_bold: { en: "Bold", sv: "Fetstil" },
89
+ format_italic: { en: "Italic", sv: "Kursiv" },
90
+ format_code: { en: "Code", sv: "Kod" },
91
+ format_heading: { en: "Heading", sv: "Rubrik" },
92
+ format_subheading: { en: "Subheading", sv: "Underrubrik" },
93
+ format_bulleted_list: { en: "Bulleted list", sv: "Punktlista" },
94
+ format_numbered_list: { en: "Numbered list", sv: "Numrerad lista" },
95
+ table: { en: "Table", sv: "Tabell" },
96
+ insert_table: { en: "Insert table", sv: "Infoga tabell" },
97
+ link: { en: "Link", sv: "Länk" },
98
+ insert_link: { en: "Insert link", sv: "Infoga länk" },
99
+ table_row_short: { en: "+ Row", sv: "+ Rad" },
100
+ table_add_row: { en: "Add row", sv: "Lägg till rad" },
101
+ table_column_short: { en: "+ Column", sv: "+ Kolumn" },
102
+ table_add_column: { en: "Add column", sv: "Lägg till kolumn" },
103
+ table_remove_row_short: { en: "− Row", sv: "− Rad" },
104
+ table_remove_row: { en: "Remove row", sv: "Ta bort rad" },
105
+ table_remove_column_short: { en: "− Column", sv: "− Kolumn" },
106
+ table_remove_column: { en: "Remove column", sv: "Ta bort kolumn" },
107
+ delete_table: { en: "Delete table", sv: "Ta bort tabell" },
108
+ link_text: { en: "Link text", sv: "Länktext" },
109
+ link_text_placeholder: { en: "Text the reader sees", sv: "Texten som läsaren ser" },
110
+ link_to_page: { en: "A page in this app", sv: "En sida i appen" },
111
+ link_to_url: { en: "An external URL", sv: "En extern webbadress" },
112
+ link_page: { en: "Page", sv: "Sida" },
113
+ link_address: { en: "Address", sv: "Adress" },
114
+ link_address_label: { en: "Link address", sv: "Länkadress" },
115
+ });
116
+
117
+ /** The language of `entry` that `locale` reads: itself, its primary language (`sv-SE` reads `sv`), else English. */
118
+ function languageIn(entry, locale) {
119
+ const ships = (language) => Object.prototype.hasOwnProperty.call(entry, language);
120
+ if (typeof locale === "string" && locale) {
121
+ if (ships(locale)) return locale;
122
+ const primary = locale.split(/[-_]/)[0].toLowerCase();
123
+ if (ships(primary)) return primary;
124
+ }
125
+ return "en";
126
+ }
127
+
128
+ function pluralCategory(language, count) {
129
+ try {
130
+ return new Intl.PluralRules(language).select(count);
131
+ } catch {
132
+ return count === 1 ? "one" : "other";
133
+ }
134
+ }
135
+
136
+ /**
137
+ * `entry`'s text in `locale`, slots filled from `values`. A plural text takes
138
+ * the form `values.count` needs, and `other` when no count is given.
139
+ */
140
+ export function textInLanguage(entry, locale, values) {
141
+ const language = languageIn(entry, locale);
142
+ const text = entry[language];
143
+ if (typeof text === "string") return fillSdkText(text, values);
144
+ const count = values ? Number(values.count) : NaN;
145
+ const form = Number.isFinite(count) ? text[pluralCategory(language, count)] : undefined;
146
+ return fillSdkText(form || text.other, values);
147
+ }
148
+
149
+ /** `text` with each `{name}` slot replaced by `values[name]`. */
150
+ export function fillSdkText(text, values) {
151
+ if (!values) return text;
152
+ return String(text).replace(/\{(\w+)\}/g, (slot, name) =>
153
+ Object.prototype.hasOwnProperty.call(values, name) ? String(values[name]) : slot,
154
+ );
155
+ }