Skip to content

Commit

Permalink
Some field name/desc translations, some prettier code
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Jul 15, 2024
1 parent 37d7345 commit c2964e7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 8 deletions.
16 changes: 16 additions & 0 deletions src/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,22 @@ config.format.help: Select the file format of the source texts. All files must b
config.format.note.pdf: The PDF file format is primarily designed for display. Please note that extracting text from them can sometimes give unsatisfactory results. Performing OCR on scanned documents is (currently) outside the scope of Mink.
config.text_annotation: Text element
config.text_annotation.help: In your source files, what XML element is most representative of a single text? Any text-level annotations will be attached to this element.
config.schema.classes: Classes
config.schema.parent: Parent
config.schema.threads: Threads
config.schema.export: Export
config.schema.word: Word
config.schema.remove_module_namespaces: Remove module namespaces
config.schema.sparv_namespace: Sparv namespace
config.schema.source_namespace: Source namespace
config.schema.scramble_on: Scramble on
config.schema.import: Import
config.schema.text_annotation: Text annotation
config.schema.source_dir: Source dir
config.schema.importer: Importer
config.schema.keep_control_chars: Keep control chars
config.schema.normalize: Normalize
config.schema.encoding: Encoding
segmenter_sentence: Existing sentence segmentation
segmenter_sentence_help: Are the text files already formatted such that sentences are separated by linebreaks?
segmenter_linebreaks: One per line
Expand Down
27 changes: 27 additions & 0 deletions src/i18n/locales/sv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,33 @@ config.format.help: Ange vilket filformat källtexterna har. Alla filer måste h
config.format.note.pdf: PDF-formatet är byggt främst för visuell presentation. Text som extraheras från PDF-filer kan ibland ge bristfälliga resultat. OCR-behandling av scannade dokument är (för närvarande) inget som Mink stödjer.
config.text_annotation: Textelement
config.text_annotation.help: Vilket XML-element i dina källfiler representerar bäst en enskild text? Eventuella annotationer på textnivå kommer att sättas på det elementet.
config.schema.classes: Klasser
config.schema.parent: Förälder
config.schema.threads: Trådar
config.schema.export: Export
config.schema.word: Ord
config.schema.word.description: Annotering att använda för tokentext i exporten
config.schema.remove_module_namespaces: Ta bort modulnamnrymder
config.schema.remove_module_namespaces.description: Ta bort modulnamnsprefix från annoteringsnamn i exporten
config.schema.sparv_namespace: Namnrymd för Sparv
config.schema.sparv_namespace.description: Prefix att lägga till på namnen för alla automatiskt skapade annoteringar
config.schema.source_namespace: Namnrymd för källa
config.schema.source_namespace.description: Prefix att lägga till på namnen för alla annoteringar från källan
config.schema.scramble_on: Nivå för omkastning
config.schema.scramble_on.description: Vilken annotering som används som minsta element vid omkastning
config.schema.import: Import
config.schema.text_annotation: Textannotering
config.schema.text_annotation.description: Annotering som representerar en text
config.schema.source_dir: Källkatalog
config.schema.source_dir.description: Katalog som innehåller korpuskällfiler
config.schema.importer: Importerare
config.schema.importer.description: Namnet på importerare att använda
config.schema.keep_control_chars: Behåll kontrolltecken
config.schema.keep_control_chars.description: Slå på för att behålla kontrolltecken
config.schema.normalize: Normalisera
config.schema.normalize.description: "Normalisera inmatning med någon av följande former: 'NFC', 'NFKC', 'NFD' eller 'NFKD'"
config.schema.encoding: Teckenkodning
config.schema.encoding.description: Teckenkodning för källfiler
segmenter_sentence: Existerande meningssegmentering
segmenter_sentence_help: Är källtexterna redan formaterade så att varje mening börjar på en ny rad?
segmenter_linebreaks: En per rad
Expand Down
21 changes: 13 additions & 8 deletions src/schema-form/JsonSchemaForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@ import { applyPureReactInVue } from "veaury";
import theme from "@/schema-form/theme/form-theme";
import useMessenger from "@/message/messenger.composable";
// Construct a RJSF form with custom theme.
const Form = withTheme(theme);
// Wrap React component, see https://github.com/gloriasoft/veaury
const VeauryForm = applyPureReactInVue(Form);
defineProps<{
schema: any;
data: D;
onChange?: (event: { formData: D }, fieldId: string) => {};
onSubmit?: (event: { formData: D }) => {};
}>();
type Error = {
// Construct a RJSF form with custom theme.
// The theme can override widget/field/template implementations.
// - widget: input element
// - field: form row, including widget, label etc
// - template: array/object wrappers, buttons etc
// https://rjsf-team.github.io/react-jsonschema-form/docs/advanced-customization/custom-themes/
const Form = withTheme(theme);
// Wrap React component, see https://github.com/gloriasoft/veaury
const VeauryForm = applyPureReactInVue(Form);
type FormInvalidError = {
message: string;
property: string;
};
const { alert } = useMessenger();
function onError(errors: Error[]) {
function onError(errors: FormInvalidError[]) {
errors.forEach((error) =>
alert(`${error.property.split(".").pop()} ${error.message}`, "error"),
);
Expand Down
9 changes: 9 additions & 0 deletions src/schema-form/theme/form-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import MoveDownButtonVue from "./MoveDownButton.vue";
const toReact = <P = {}>(component: Component) =>
applyPureVueInReact(component) as React.ComponentType<P>;

// https://rjsf-team.github.io/react-jsonschema-form/docs/advanced-customization/custom-widgets-fields
const widgets: FormProps["widgets"] = {};

// https://rjsf-team.github.io/react-jsonschema-form/docs/advanced-customization/custom-widgets-fields
const fields: FormProps["fields"] = {};

// https://rjsf-team.github.io/react-jsonschema-form/docs/advanced-customization/custom-themes/#templates
const templates: FormProps["templates"] = {
ButtonTemplates: {
AddButton: toReact<IconButtonProps>(AddButtonVue),
Expand All @@ -22,6 +29,8 @@ const templates: FormProps["templates"] = {
};

const theme: ThemeProps = {
widgets,
fields,
templates,
};
export default theme;

0 comments on commit c2964e7

Please sign in to comment.