From 42b4b18bb77b8870c5dc7ba1cd8e02cd23f1c96f Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Wed, 4 Oct 2023 15:37:11 -0700 Subject: [PATCH] [CL-134] Switch back to bit-i18n-part directive name --- ...ag.directive.ts => i18n-part.directive.ts} | 4 +-- libs/components/src/i18n/i18n.component.ts | 12 ++++----- libs/components/src/i18n/i18n.mdx | 26 +++++++++---------- libs/components/src/i18n/i18n.module.ts | 6 ++--- libs/components/src/i18n/i18n.stories.ts | 18 ++++++------- 5 files changed, 33 insertions(+), 33 deletions(-) rename libs/components/src/i18n/{i18n-tag.directive.ts => i18n-part.directive.ts} (86%) diff --git a/libs/components/src/i18n/i18n-tag.directive.ts b/libs/components/src/i18n/i18n-part.directive.ts similarity index 86% rename from libs/components/src/i18n/i18n-tag.directive.ts rename to libs/components/src/i18n/i18n-part.directive.ts index 6421ea92c81..0cdd470c734 100644 --- a/libs/components/src/i18n/i18n-tag.directive.ts +++ b/libs/components/src/i18n/i18n-part.directive.ts @@ -7,8 +7,8 @@ import { Directive, TemplateRef } from "@angular/core"; * {{text}} */ @Directive({ - selector: "[bit-i18n-tag]", + selector: "[bit-i18n-part]", }) -export class I18nTagDirective { +export class I18nPartDirective { constructor(public templateRef: TemplateRef) {} } diff --git a/libs/components/src/i18n/i18n.component.ts b/libs/components/src/i18n/i18n.component.ts index dddca19028e..9cd3ecb67b8 100644 --- a/libs/components/src/i18n/i18n.component.ts +++ b/libs/components/src/i18n/i18n.component.ts @@ -9,7 +9,7 @@ import { import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { I18nTagDirective } from "./i18n-tag.directive"; +import { I18nPartDirective } from "./i18n-part.directive"; interface I18nStringPart { text: string; @@ -25,13 +25,13 @@ interface I18nStringPart { * `"This will be a <0>translated link and this will be another <1>translated link."` * * The tag identifiers must be numbers surrounded by angle brackets and will be used to match the corresponding - * bit-i18n-tag. If there are not enough bit-i18n-tag directives, the text will be rendered as-is for the remaining + * bit-i18n-part. If there are not enough bit-i18n-part directives, the text will be rendered as-is for the remaining * tags. * * @example *
- * {{ text }} - * + * {{ text }} + * * {{ text }} * *
@@ -59,8 +59,8 @@ export class I18nComponent implements AfterContentInit { @Input() args: (string | number)[] = []; - @ContentChildren(I18nTagDirective) - templateTags: QueryList; + @ContentChildren(I18nPartDirective) + templateTags: QueryList; protected translationParts: I18nStringPart[] = []; diff --git a/libs/components/src/i18n/i18n.mdx b/libs/components/src/i18n/i18n.mdx index 0bda24c51c8..507886c0a8f 100644 --- a/libs/components/src/i18n/i18n.mdx +++ b/libs/components/src/i18n/i18n.mdx @@ -13,10 +13,10 @@ target language. The templating syntax uses numeric marker tags `<0>` around text that will be wrapped. The marker tags should numbered sequentially starting from 0. The marker tags are then matched and -replaced by the `*bit-i18n-tag` directives in the order they appear in the template. +replaced by the `*bit-i18n-part` directives in the order they appear in the template. -If a corresponding `*bit-i18n-tag` directive is not found for a marker tag, the marker tag's content -will be rendered as is. +If a corresponding `*bit-i18n-part` directive is not found for a marker tag, the marker tag's +content will be rendered as is. ## Basic Example @@ -33,11 +33,11 @@ will be rendered as is. --> - {{ text }} + {{ text }} - {{ text }} + {{ text }} - + {{ text }} @@ -58,15 +58,15 @@ You can also use the `bit-i18n` as an attribute to avoid creating an extra eleme "This is another example with <1>bold tags to show that tag order does not matter and the <0>link tags are after." -->

- {{ text }} - {{ text }} + {{ text }} + {{ text }}

``` ## Missing Template Example -If there are not enough `*bit-i18n-tag` directives to match the marker tags, the marker tags will be -rendered as is. +If there are not enough `*bit-i18n-part` directives to match the marker tags, the marker tags will +be rendered as is. @@ -81,9 +81,9 @@ rendered as is. --> - {{ text }} + {{ text }} - {{ text }} + {{ text }} ``` @@ -104,6 +104,6 @@ You can also pass arguments to the `i18nService.t()` method via the `[args]` inp --> - {{ text }} + {{ text }} ``` diff --git a/libs/components/src/i18n/i18n.module.ts b/libs/components/src/i18n/i18n.module.ts index 795475c4fa7..85f935d58e7 100644 --- a/libs/components/src/i18n/i18n.module.ts +++ b/libs/components/src/i18n/i18n.module.ts @@ -2,12 +2,12 @@ import { NgModule } from "@angular/core"; import { SharedModule } from "../shared"; -import { I18nTagDirective } from "./i18n-tag.directive"; +import { I18nPartDirective } from "./i18n-part.directive"; import { I18nComponent } from "./i18n.component"; @NgModule({ imports: [SharedModule], - declarations: [I18nComponent, I18nTagDirective], - exports: [I18nComponent, I18nTagDirective], + declarations: [I18nComponent, I18nPartDirective], + exports: [I18nComponent, I18nPartDirective], }) export class I18nModule {} diff --git a/libs/components/src/i18n/i18n.stories.ts b/libs/components/src/i18n/i18n.stories.ts index 5c1f842da53..c0e5f061012 100644 --- a/libs/components/src/i18n/i18n.stories.ts +++ b/libs/components/src/i18n/i18n.stories.ts @@ -42,9 +42,9 @@ export const Basic: Story = { props: args, template: ` - {{ text }} - {{ text }} - + {{ text }} + {{ text }} + {{ text }} @@ -57,8 +57,8 @@ export const AttributeSelector: Story = { props: args, template: `

- {{ text }} - {{ text }} + {{ text }} + {{ text }}

`, }), @@ -69,8 +69,8 @@ export const ArgsExample: Story = { props: args, template: `

- {{ text }} - {{ text }} + {{ text }} + {{ text }}

`, }), @@ -81,8 +81,8 @@ export const MissingTemplate: Story = { props: args, template: `

- {{ text }} - {{ text }} + {{ text }} + {{ text }}

`, }),