@@ -134,12 +134,13 @@ def gen_response_object(description: str, media_type: str,
134134 return response
135135
136136
137- def gen_contact (cfg : dict ) -> dict :
137+ def gen_contact (cfg : dict , locale_ : str ) -> dict :
138138 """
139139 Generates an OpenAPI contact object with OGC extensions
140140 based on OGC API - Records contact
141141
142142 :param cfg: `dict` of configuration
143+ :param locale_: `str` of locale
143144
144145 :returns: `dict` of OpenAPI contact object
145146 """
@@ -148,40 +149,47 @@ def gen_contact(cfg: dict) -> dict:
148149 has_phones = False
149150
150151 contact = {
151- 'name' : cfg ['metadata' ]['provider' ]['name' ]
152+ 'name' : l10n . translate ( cfg ['metadata' ]['provider' ]['name' ], locale_ )
152153 }
153154
154155 for key in ['url' , 'email' ]:
155156 if key in cfg ['metadata' ]['provider' ]:
156- contact [key ] = cfg ['metadata' ]['provider' ][key ]
157+ contact [key ] = l10n .translate (cfg ['metadata' ]['provider' ][key ],
158+ locale_ )
157159
158160 contact ['x-ogc-serviceContact' ] = {
159- 'name' : cfg ['metadata' ]['contact' ]['name' ],
161+ 'name' : l10n . translate ( cfg ['metadata' ]['contact' ]['name' ], locale_ ) ,
160162 'addresses' : []
161163 }
162164
163165 if 'position' in cfg ['metadata' ]['contact' ]:
164- contact ['x-ogc-serviceContact' ]['position' ] = cfg ['metadata' ]['contact' ]['position' ] # noqa
166+ contact ['x-ogc-serviceContact' ]['position' ] = l10n .translate (
167+ cfg ['metadata' ]['contact' ]['position' ], locale_ )
165168
166169 if any (address in ['address' , 'city' , 'stateorprovince' , 'postalcode' , 'country' ] for address in cfg ['metadata' ]['contact' ]): # noqa
167170 has_addresses = True
168171
169172 if has_addresses :
170173 address = {}
171174 if 'address' in cfg ['metadata' ]['contact' ]:
172- address ['deliveryPoint' ] = [cfg ['metadata' ]['contact' ]['address' ]]
175+ address ['deliveryPoint' ] = [l10n .translate (
176+ cfg ['metadata' ]['contact' ]['address' ], locale_ )]
173177
174178 if 'city' in cfg ['metadata' ]['contact' ]:
175- address ['city' ] = cfg ['metadata' ]['contact' ]['city' ]
179+ address ['city' ] = l10n .translate (
180+ cfg ['metadata' ]['contact' ]['city' ], locale_ )
176181
177182 if 'stateorprovince' in cfg ['metadata' ]['contact' ]:
178- address ['administrativeArea' ] = cfg ['metadata' ]['contact' ]['stateorprovince' ] # noqa
183+ address ['administrativeArea' ] = l10n .translate (
184+ cfg ['metadata' ]['contact' ]['stateorprovince' ], locale_ )
179185
180186 if 'postalCode' in cfg ['metadata' ]['contact' ]:
181- address ['administrativeArea' ] = cfg ['metadata' ]['contact' ]['postalCode' ] # noqa
187+ address ['administrativeArea' ] = l10n .translate (
188+ cfg ['metadata' ]['contact' ]['postalCode' ], locale_ )
182189
183190 if 'country' in cfg ['metadata' ]['contact' ]:
184- address ['administrativeArea' ] = cfg ['metadata' ]['contact' ]['country' ] # noqa
191+ address ['administrativeArea' ] = l10n .translate (
192+ cfg ['metadata' ]['contact' ]['country' ], locale_ )
185193
186194 contact ['x-ogc-serviceContact' ]['addresses' ].append (address )
187195
@@ -192,33 +200,39 @@ def gen_contact(cfg: dict) -> dict:
192200 if has_phones :
193201 if 'phone' in cfg ['metadata' ]['contact' ]:
194202 contact ['x-ogc-serviceContact' ]['phones' ].append ({
195- 'type' : 'main' , 'value' : cfg ['metadata' ]['contact' ]['phone' ]
203+ 'type' : 'main' , 'value' : l10n .translate (
204+ cfg ['metadata' ]['contact' ]['phone' ], locale_ )
196205 })
197206
198207 if 'fax' in cfg ['metadata' ]['contact' ]:
199208 contact ['x-ogc-serviceContact' ]['phones' ].append ({
200- 'type' : 'fax' , 'value' : cfg ['metadata' ]['contact' ]['fax' ]
209+ 'type' : 'fax' , 'value' : l10n .translate (
210+ cfg ['metadata' ]['contact' ]['fax' ], locale_ )
201211 })
202212
203213 if 'email' in cfg ['metadata' ]['contact' ]:
204214 contact ['x-ogc-serviceContact' ]['emails' ] = [{
205- 'value' : cfg ['metadata' ]['contact' ]['email' ]
215+ 'value' : l10n .translate (
216+ cfg ['metadata' ]['contact' ]['email' ], locale_ )
206217 }]
207218
208219 if 'url' in cfg ['metadata' ]['contact' ]:
209220 contact ['x-ogc-serviceContact' ]['links' ] = [{
210221 'type' : 'text/html' ,
211- 'href' : cfg ['metadata' ]['contact' ]['url' ]
222+ 'href' : l10n . translate ( cfg ['metadata' ]['contact' ]['url' ], locale_ )
212223 }]
213224
214225 if 'instructions' in cfg ['metadata' ]['contact' ]:
215- contact ['x-ogc-serviceContact' ]['contactInstructions' ] = cfg ['metadata' ]['contact' ]['instructions' ] # noqa
226+ contact ['x-ogc-serviceContact' ]['contactInstructions' ] = l10n .translate ( # noqa
227+ cfg ['metadata' ]['contact' ]['instructions' ], locale_ )
216228
217229 if 'hours' in cfg ['metadata' ]['contact' ]:
218- contact ['x-ogc-serviceContact' ]['hoursOfService' ] = cfg ['metadata' ]['contact' ]['hours' ] # noqa
230+ contact ['x-ogc-serviceContact' ]['hoursOfService' ] = l10n .translate (
231+ cfg ['metadata' ]['contact' ]['hours' ], locale_ )
219232
220233 if 'role' in cfg ['metadata' ]['contact' ]:
221- contact ['x-ogc-serviceContact' ]['hoursOfService' ] = cfg ['metadata' ]['contact' ]['role' ] # noqa
234+ contact ['x-ogc-serviceContact' ]['hoursOfService' ] = l10n .translate (
235+ cfg ['metadata' ]['contact' ]['role' ], locale_ )
222236
223237 return contact
224238
@@ -255,11 +269,11 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:
255269 'description' : l10n .translate (cfg ['metadata' ]['identification' ]['description' ], locale_ ), # noqa
256270 'x-keywords' : l10n .translate (cfg ['metadata' ]['identification' ]['keywords' ], locale_ ), # noqa
257271 'termsOfService' :
258- cfg ['metadata' ]['identification' ]['terms_of_service' ],
259- 'contact' : gen_contact (cfg ),
272+ l10n . translate ( cfg ['metadata' ]['identification' ]['terms_of_service' ], locale_ ), # noqa
273+ 'contact' : gen_contact (cfg , locale_ ),
260274 'license' : {
261- 'name' : cfg ['metadata' ]['license' ]['name' ],
262- 'url' : cfg ['metadata' ]['license' ]['url' ]
275+ 'name' : l10n . translate ( cfg ['metadata' ]['license' ]['name' ], locale_ ), # noqa
276+ 'url' : l10n . translate ( cfg ['metadata' ]['license' ]['url' ], locale_ )
263277 },
264278 'version' : api_rules .api_version
265279 }
@@ -360,7 +374,7 @@ def get_oas_30(cfg: dict, fail_on_invalid_collection: bool = True) -> dict:
360374 'description' : l10n .translate (cfg ['metadata' ]['identification' ]['description' ], locale_ ), # noqa
361375 'externalDocs' : {
362376 'description' : 'information' ,
363- 'url' : cfg ['metadata' ]['identification' ]['url' ]}
377+ 'url' : l10n . translate ( cfg ['metadata' ]['identification' ]['url' ], locale_ )} # noqa
364378 }
365379 )
366380
0 commit comments