Skip to content

Commit 86d3e6a

Browse files
authored
feat: add romansh (DEV-867) (#193)
1 parent ed35902 commit 86d3e6a

11 files changed

Lines changed: 42 additions & 234 deletions

‎docs/dsp-tools-create-ontologies.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ By convention, property names start with a lower case letter.
141141

142142
`"labels": {"<language>": "<string>", ...}`
143143

144-
Collection of `labels` for the property as strings with language tag (currently "en", "de", "fr"
145-
and "it" are supported).
144+
Collection of `labels` for the property as strings with language tag (currently "en", "de", "fr", "it",
145+
and "rm" are supported).
146146

147147
### Comments
148148

149149
(optional)
150150

151151
`"comments": { "<lang>": "<comment>", "<lang>": "<comment>", ... }`
152152

153-
Comments with language tags. Currently, "de", "en", "fr" and "it" are supported. The `comments` element is optional.
153+
Comments with language tags. Currently, "de", "en", "fr", "it", and "rm" are supported. The `comments` element is optional.
154154

155155
### Super
156156

@@ -780,8 +780,8 @@ By convention, resource names start with a upper case letter.
780780

781781
`"labels": {"<language>": "<string>", ...}`
782782

783-
Collection of `labels` for the resource as strings with language tag (currently "en", "de", "fr"
784-
and "it" are supported).
783+
Collection of `labels` for the resource as strings with language tag (currently "en", "de", "fr", "it",
784+
and "rm" are supported).
785785

786786
### Super
787787

@@ -844,7 +844,7 @@ resource can have as well as how many times the relation is established.
844844

845845
`"comments": { "<lang>": "<comment>", "<lang>": "<comment>", ... }`
846846

847-
Comments with language tags. Currently, "de", "en", "fr" and "it" are supported. The `comments` element is optional.
847+
Comments with language tags. Currently, "de", "en", "fr", "it", and "rm" are supported. The `comments` element is optional.
848848

849849
Example for a resource definition:
850850

‎docs/dsp-tools-create.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ The longname is a string that provides the full name of the project.
167167

168168
`"descriptions": {"<lang>": "<string>", ...}`
169169

170-
The description is represented as a collection of strings with language tags (currently "en", "de", "fr" and "it" are
170+
The description is represented as a collection of strings with language tags (currently "en", "de", "fr", "it", and "rm" are
171171
supported). It is the description of the project.
172172

173173
### Keywords
@@ -201,9 +201,9 @@ A node of a list may have the following elements:
201201

202202
- _name_: Name of the node as string. It is mandatory and has to be unique within the list.
203203
- _labels_: Label with language tags in the form `{ "<lang>": "<label>", "<lang>": "<label>", ... }`. The `labels`
204-
element is mandatory. It needs to specify at least one language. Currently, "de", "en", "fr" and "it" are supported.
204+
element is mandatory. It needs to specify at least one language. Currently, "de", "en", "fr", "it", and "rm" are supported.
205205
- _comments_: Comment with language tags in the form `{ "<lang>": "<comment>", "<lang>": "<comment>", ... }`.
206-
Currently, "de", "en", "fr" and "it" are supported. The `comments` element is mandatory for the root node of the list.
206+
Currently, "de", "en", "fr", "it", and "rm" are supported. The `comments` element is mandatory for the root node of the list.
207207
For all other nodes, it is optional. If not used, the element should be omitted.
208208
- _nodes_: Array of sub-nodes. The `nodes` element is optional and can be omitted in case of a flat list.
209209

@@ -360,7 +360,7 @@ A group definition has the following elements:
360360

361361
- _name_: name of the group, mandatory
362362
- _descriptions_: description of the group with language tags in the form `"descriptions": {"<lang>": "<string>", ...}` (
363-
currently "en", "de", "fr" and "it" are supported), mandatory
363+
currently "en", "de", "fr", "it", and "rm" are supported), mandatory
364364
- _selfjoin_: true if users are allowed to join the group themselves, false if an administrator has to add the users,
365365
optional
366366
- _status_: true if the group is active, false if the group is inactive, optional

‎knora/dsplib/models/group.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Group(Model):
5454
Name of the group
5555
5656
descriptions : LangString
57-
Group descriptions in a given language (Languages.EN, Languages.DE, Languages.FR, Languages.IT).
57+
Group descriptions in a given language (Languages.EN, Languages.DE, Languages.FR, Languages.IT, Languages.RM).
5858
5959
project : str | project
6060
either the IRI of a project [get only, cannot be modified after creation of instance]

‎knora/dsplib/models/langstring.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Languages(Enum):
1010
DE = 'de'
1111
FR = 'fr'
1212
IT = 'it'
13+
RM = 'rm'
1314

1415

1516
LangStringParam = Optional[Union[dict[Union[Languages, str], str], str]]
@@ -224,6 +225,8 @@ def fromJsonLdObj(cls, obj: Optional[Union[list[dict[str, str]], str]]) -> 'Lang
224225
lstrs[Languages.FR] = o.get('@value')
225226
elif lang == 'it':
226227
lstrs[Languages.IT] = o.get('@value')
228+
elif lang == 'rm':
229+
lstrs[Languages.RM] = o.get('@value')
227230
else:
228231
if o.get('@value') is not None:
229232
return cls(o.get('@value'))
@@ -250,6 +253,8 @@ def fromJsonObj(cls, obj: Optional[Any]) -> 'LangString':
250253
lstrs[Languages.FR] = o.get('value')
251254
elif lang == 'it':
252255
lstrs[Languages.IT] = o.get('value')
256+
elif lang == 'rm':
257+
lstrs[Languages.RM] = o.get('value')
253258
else:
254259
if o.get('value') is not None:
255260
return cls(o.get('value'))

‎knora/dsplib/schemas/lists-only.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"langstring": {
88
"type": "object",
99
"patternProperties": {
10-
"^(en|de|fr|it)": {
10+
"^(en|de|fr|it|rm)$": {
1111
"type": "string"
1212
}
1313
},
@@ -19,7 +19,7 @@
1919
"comment": {
2020
"type": "object",
2121
"patternProperties": {
22-
"^(en|de|fr|it)": {
22+
"^(en|de|fr|it|rm)$": {
2323
"type": "string"
2424
}
2525
},

‎knora/dsplib/schemas/ontology.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"langstring": {
88
"type": "object",
99
"patternProperties": {
10-
"^(en|de|fr|it)": {
10+
"^(en|de|fr|it|rm)$": {
1111
"type": "string"
1212
}
1313
},
@@ -126,7 +126,7 @@
126126
},
127127
"lang": {
128128
"type": "string",
129-
"pattern": "^(en|de|fr|it)"
129+
"pattern": "^(en|de|fr|it|rm)$"
130130
},
131131
"groups": {
132132
"type": "array",

‎knora/dsplib/schemas/properties-only.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"langstring": {
88
"type": "object",
99
"patternProperties": {
10-
"^(en|de|fr|it)": {
10+
"^(en|de|fr|it|rm)$": {
1111
"type": "string"
1212
}
1313
},

‎knora/dsplib/schemas/resources-only.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"langstring": {
88
"type": "object",
99
"patternProperties": {
10-
"^(en|de|fr|it)": {
10+
"^(en|de|fr|it|rm)$": {
1111
"type": "string"
1212
}
1313
},

‎knora/dsplib/utils/excel_to_json_lists.py‎

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -220,26 +220,6 @@ def simplify_name(value: str) -> str:
220220
return simplified_value
221221

222222

223-
def check_language_code(lang_code: str) -> bool:
224-
"""
225-
Checks if a given language code is valid. The code is valid if it is listed in language-codes-3b2_csv.csv. This
226-
file provides all ISO 639-1 and ISO 639-2 language codes.
227-
228-
Args:
229-
lang_code: the language code to be checked
230-
231-
Returns:
232-
True if valid, False if not
233-
"""
234-
current_dir = os.path.dirname(os.path.realpath(__file__))
235-
with open(os.path.join(current_dir, 'language-codes-3b2_csv.csv'), 'r') as language_codes_file:
236-
language_codes = csv.reader(language_codes_file, delimiter=',')
237-
for row in language_codes:
238-
if lang_code in row:
239-
return True
240-
return False
241-
242-
243223
def make_root_node_from_args(
244224
excelfiles: list[str],
245225
listname_from_args: Optional[str],
@@ -264,9 +244,8 @@ def make_root_node_from_args(
264244
basename = os.path.basename(filename)
265245
lang_specific_listname, lang_code = os.path.splitext(basename)[0].rsplit('_', 1)
266246

267-
if not check_language_code(lang_code):
268-
print(f'Invalid language code "{lang_code}" is used. Only language codes from ISO 639-1 ',
269-
f'and ISO 639-2 are accepted.')
247+
if lang_code not in ['en', 'de', 'fr', 'it', 'rm']:
248+
print(f'Invalid language code "{lang_code}" is used. Only en, de, fr, it, and rm are accepted.')
270249
quit()
271250

272251
listname_from_lang_code[lang_code] = lang_specific_listname

‎knora/dsplib/utils/language-codes-3b2_csv.csv‎

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)