Commit graph

5 commits

Author SHA1 Message Date
Luke Elmers
b6287708f6
Adds AGPL 3.0 license (#192025)
Updates files outside of x-pack to be triple-licensed under Elastic
License 2.0, AGPL 3.0, or SSPL 1.0.
2024-09-06 19:02:41 -06:00
Coen Warmer
d7b1dfd7fe
[ESLint i18n Rules] Fix issue with quotes in text strings (#181592)
## Summary

This fixes an issue where strings with a quote in it would not get
correctly escaped, leading to the ESLint rule autofix suggestion leading
to non-compiling javascript.
2024-04-26 03:19:52 -07:00
Coen Warmer
87969edb2b
[i18n ESLint Rule] Better cleaning of string values (#174360)
## Summary

This fixes incorrect stripping of special characters when setting
default translated values.

## Longer

The i18n rule would incorrectly strip certain characters such as commas,
periods and other non alphanumerical characters from the default value.

Example:

This input:

```
import React from 'react';

export function Foo() {
  return (
    <SomeComp>See, this example!</SomeComp>
  )
}
```

Would be autofixed to:

```
import React from 'react';
import { i18n } from '@kbn/i18n';

export function Foo() {
  return (
    <SomeComp>
      {i18n.translate('foo.someComp.seeThisExample', { defaultMessage: 'See this example' })}
    </SomeComp>
  )
}
```
Special characters were incorrectly stripped from `defaultMessage`.

Now, the autofix results in:

```
import React from 'react';
import { i18n } from '@kbn/i18n';

export function Foo() {
  return (
    <SomeComp>
      {i18n.translate('foo.someComp.seeThisExample', { defaultMessage: 'See, this example!' })}
    </SomeComp>
  )
}
```
2024-01-08 05:01:58 -07:00
Coen Warmer
4493efa9a9
i18n Translation ESLint Rule Fixes And Improvements (#169955) 2023-10-30 18:42:04 +01:00
Coen Warmer
6fcf8c9efe
Add ESLint rule for Translations (#168001)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jon <jon@budzenski.me>
2023-10-16 18:34:50 +02:00