vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Define components in PascalCase

Open wopian opened this issue 3 years ago • 2 comments
trafficstars

Clear and concise description of the problem

Currently vue-i18n@next only exposes components as kebab-case, which is in direct conflict with our ESLint rules which forbid kebab-case component names.

PascalCase cannot be used if components are defined as kebab-case, so we're currently having to ignore this rule for i18n's component names.

Related to https://github.com/kazupon/vue-i18n/issues/1196 in the Vue 2 repo

Suggested solution

Define components as PascalCase. This allows consumers to use either PascalCase or kebab-case in their templates as PascalCase supports both usages and would not be a breaking change - see https://v3.vuejs.org/guide/component-registration.html#name-casing for details

Alternative

No response

Additional context

// .eslintrc.js
export default {
  ...,
  rules: {
	...,
    'vue/component-name-in-template-casing': [
      'error',
      'PascalCase',
      { registeredComponentsOnly: false, ignores: ['i18n-t'] }
    ],
  }
}

Validations

wopian avatar Dec 08 '21 10:12 wopian

Hi, what about importing the component like this:

import {I18nT, useI18n} from 'vue-i18n';

This would allow you to use the pascal case name, plus you get intellisense/autocomplete,

I started this discussion here

santiagoarizti avatar Jan 10 '22 19:01 santiagoarizti

Hi, what about importing the component like this:

import {I18nT, useI18n} from 'vue-i18n';

This would allow you to use the pascal case name, plus you get intellisense/autocomplete,

I started this discussion here

Component registration can be global, it'd be better to have multiple Translation component names at
https://github.com/intlify/vue-i18n-next/blob/master/packages/vue-i18n-core/src/components/Translation.ts#L83

Miguel-Bento-Github avatar Aug 08 '22 13:08 Miguel-Bento-Github