feat(shared): Use i18n-next for example translations
This commit is contained in:
parent
a867666b9d
commit
7aba490544
2 changed files with 13 additions and 15 deletions
|
@ -1,21 +1,20 @@
|
|||
import React from 'react'
|
||||
import { strings } from '@freesewing/i18n'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
const TextOnPath = (props) => {
|
||||
let text = []
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const text = []
|
||||
// Handle translation
|
||||
let translated = ''
|
||||
for (let string of props.path.attributes.getAsArray('data-text')) {
|
||||
if (strings[props.language]['plugin.' + string])
|
||||
translated += strings[props.language]['plugin.' + string]
|
||||
else translated += string.toString().replace(/"/g, '"')
|
||||
translated += t(string)
|
||||
translated += ' '
|
||||
}
|
||||
let textPathProps = {
|
||||
const textPathProps = {
|
||||
xlinkHref: '#' + props.pathId,
|
||||
startOffset: '0%'
|
||||
}
|
||||
let align = props.path.attributes.get('data-text-class')
|
||||
const align = props.path.attributes.get('data-text-class')
|
||||
if (align && align.indexOf('center') > -1) textPathProps.startOffset = '50%'
|
||||
else if (align && align.indexOf('right') > -1) textPathProps.startOffset = '100%'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue