GithubHelp home page GithubHelp logo

Comments (4)

justin-schroeder avatar justin-schroeder commented on September 26, 2024 1

Looks like your file is still TypeScript and you dont have a ts interpreter on your project. if you do, then make sure your file ends in a .ts either way, we'll get this in the next release.

from formkit.

r-martins avatar r-martins commented on September 26, 2024

There's no way to use this translation before you approve the PR?!

from formkit.

justin-schroeder avatar justin-schroeder commented on September 26, 2024

@r-martins you can! Just create your own file, and import it to where you register the FormKit plugin with Vue:

import { createApp } from 'vue'
import App from './App.vue'
import { plugin, defaultConfig } from '@formkit/vue'
import br from './br.ts'

createApp(App).use(plugin, defaultConfig({
  locales: { br },
  locale: 'br'
}).mount('#app')

Assuming your project is setup for typescript (otherwise you'll obviously need to strip out the typescript parts to make it JS again), you’ll need to make one code change to your br.ts and that is to change the imports to be from the main package:

import { FormKitValidationMessages } from '@formkit/validation'

/**
 * Here we can import additional helper functions to assist in formatting our
 * language. Feel free to add additional helper methods to libs/formats if it
 * assists in creating good validation messages for your locale.
 */
import { sentence as s, list, date } from '@formkit/i18n'
import { FormKitLocaleMessages } from '@formkit/i18n'

But basically, there is no magic here, you just need to provide your locale to the locales key in the defaultConfig, and then select it with the locale option.

Thanks for providing the translation!

from formkit.

r-martins avatar r-martins commented on September 26, 2024

Hi @justin-schroeder
Thanks for replying.
I don't know if I got it right, but my pt.js is like you mentioned...

import { FormKitValidationMessages } from '@formkit/validation'

/**
 * Here we can import additional helper functions to assist in formatting our
 * language. Feel free to add additional helper methods to libs/formats if it
 * assists in creating good validation messages for your locale.
 */
import { sentence as s, list, date } from '@formkit/i18n'
import { FormKitLocaleMessages } from '@formkit/i18n'

And I've added it to main.js:

import {createApp} from 'vue'
import App from './App.vue'

import {defaultConfig, plugin} from "@formkit/vue"
import br from './pt.ts'

createApp(App).use(plugin, defaultConfig({
    locales: {pt},
    locale: 'pt'
})).mount('#app')

Then I got the following error:

ERROR Failed to compile with 1 error 10:38:56 AM

error in ./src/pt.ts

Module parse failed: Unexpected token (15:15)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| * @public
| */

export const ui: FormKitLocaleMessages = {
| /**
| * Shown when a button to remove items is visible.

@ ./src/main.js 5:0-24
@ multi (webpack)-dev-server/client?http://localhost:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

from formkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.