💚 répare les tests et lance prettier après la traduction auto
parent
8631d47ace
commit
7ec1234638
|
@ -1,5 +1,6 @@
|
|||
var { stringify } = require('yaml')
|
||||
var fs = require('fs')
|
||||
var prettier = require('prettier')
|
||||
|
||||
const {
|
||||
getRulesMissingTranslations,
|
||||
|
@ -18,12 +19,17 @@ missingTranslations.forEach(async ([dottedName, attr, value]) => {
|
|||
try {
|
||||
const translation = await fetchTranslation(value)
|
||||
resolved[dottedName][attr] = '[automatic] ' + translation
|
||||
// C'est très bourrin, mais on ne veut pas perdre une traduction qu'on a payé
|
||||
fs.writeFileSync(
|
||||
rulesTranslationPath,
|
||||
stringify(resolved, { sortMapEntries: true })
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
})
|
||||
|
||||
prettier.resolveConfig(rulesTranslationPath).then(options => {
|
||||
fs.writeFileSync(
|
||||
rulesTranslationPath,
|
||||
prettier.format(stringify(resolved, { sortMapEntries: true }), {
|
||||
...options,
|
||||
parser: 'yaml'
|
||||
})
|
||||
)
|
||||
})
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -107,11 +107,23 @@ type Options = {
|
|||
precision?: number
|
||||
}
|
||||
|
||||
type Commune = {
|
||||
nom: string
|
||||
codePostal?: string
|
||||
departement: { nom: string }
|
||||
}
|
||||
|
||||
function formatCommune(commune: Commune) {
|
||||
return `${commune.nom} (${commune.codePostal ?? commune.departement.nom})`
|
||||
}
|
||||
export function formatValue(
|
||||
value:
|
||||
| number
|
||||
| { nodeValue: Evaluation; unit?: Unit }
|
||||
| { nodeValue: { nom: string; code: string }; API: 'commune' }
|
||||
| {
|
||||
nodeValue: Commune
|
||||
API: 'commune'
|
||||
}
|
||||
| undefined,
|
||||
|
||||
{ language = 'fr', displayedUnit, precision = 2 }: Options = {}
|
||||
|
@ -138,7 +150,7 @@ export function formatValue(
|
|||
return typeof nodeValue === 'string'
|
||||
? capitalise0(nodeValue)
|
||||
: typeof value === 'object' && 'API' in value && value.API === 'commune'
|
||||
? `${(nodeValue as any).nom} (${(nodeValue as any).code})`
|
||||
? formatCommune(nodeValue as Commune)
|
||||
: typeof nodeValue === 'object'
|
||||
? (nodeValue as any).nom
|
||||
: typeof nodeValue === 'boolean'
|
||||
|
|
Loading…
Reference in New Issue