Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All strings displayed in the UI should be externalised #453

Closed
79 tasks done
AlanGreene opened this issue Aug 28, 2019 · 4 comments · Fixed by #1447
Closed
79 tasks done

All strings displayed in the UI should be externalised #453

AlanGreene opened this issue Aug 28, 2019 · 4 comments · Fixed by #1447
Assignees

Comments

@AlanGreene
Copy link
Member

AlanGreene commented Aug 28, 2019

Expected Behavior

It should be possible to customise / translate all strings displayed in the UI (excluding user data or error messages provided by the environment).

Actual Behavior

Many strings are still hard-coded in the components instead of using react-intl.

Additional Info

We have begun extracting strings as described, this process should be completed and all new strings added using react-intl to avoid building up additional debt.

Some of the components that have been migrated to @tektoncd/dashboard-components have been partially updated and need to be revisited to ensure no hardcoded strings remain.

We also need to ensure the process for adding new strings is clearly documented in https://github.com/tektoncd/dashboard/blob/master/DEVELOPMENT.md or other appropriate location. Tooling should also be added to avoid manual steps to build the externalised list of current strings.

@tektoncd/dashboard-components

  • Breadcrumbs (likely to be removed in design update, 'Import Tekton Resources' is the only string that would need to be extracted otherwise)
  • CancelButton
  • ErrorBoundary
  • Header
  • KeyValueList
  • LabelFilter
  • Log
  • LogoutButton
  • PageErrorBoundary
  • PipelineResources
  • PipelineRun
  • PipelineRuns
  • Rerun
  • ResourceTable
  • RunDropdown
  • RunHeader
  • Spinner
  • Step
  • StepDefinition
    • Parameters, Input Resources, Output Resources
  • StepDetails
  • StepDetailsHeader
  • StepStatus
  • Tab
  • Table
  • Tabs
  • Task
  • TaskRuns
  • TaskSkeleton
  • TaskTree
  • Trigger
  • ViewYAML

src/components

  • PipelineResourcesModal
    • GitResourceFields
    • UniversalFields
  • SecretsDeleteModal
  • SecretsModal
    • BasicAuthFields
    • UniversalFields
  • TextInput
  • TooltipDropdown

src/containers

  • App
  • ClusterTasks
  • CreatePipelineRun
  • CustomResourceDefinition
  • EventListener
  • EventListeners
  • Extension
  • Extensions
  • ImportResources
  • NamespacesDropdown
  • PipelineResource
  • PipelineResources
  • PipelineResourcesDropdown
  • PipelineResourcesModal
  • PipelineRun
  • PipelineRuns
  • Pipelines
  • PipelinesDropdown
  • ResourceList
  • Secrets
  • SecretsModal
  • ServiceAccount
  • ServiceAccounts
  • ServiceAccountsDropdown
  • SideNav
    • Tekton resources, Import Tekton resources
  • TaskRun
  • TaskRuns
  • Tasks
  • TriggerBinding
  • TriggerBindings
  • TriggerTemplate
  • TriggerTemplates

Carbon components

Some Carbon components provide default strings internally, such as the '{n} rows selected' batch selection text on a DataTable. Translations for these strings can be overridden by providing a custom translateWithId function as a prop to these components, to convert the provided translationKeys into the desired string using any i18n library / approach.

  • DataTable. Default implementation below:
    const translationKeys = {
      expandRow: 'carbon.table.row.expand',
      collapseRow: 'carbon.table.row.collapse',
      expandAll: 'carbon.table.all.expand',
      collapseAll: 'carbon.table.all.collapse',
      selectAll: 'carbon.table.all.select',
      unselectAll: 'carbon.table.all.unselect',
      selectRow: 'carbon.table.row.select',
      unselectRow: 'carbon.table.row.unselect',
    };
    
    const defaultTranslations = {
      /* NOT CURRENTLY USED IN DASHBOARD
      [translationKeys.expandAll]: 'Expand all rows',
      [translationKeys.collapseAll]: 'Collapse all rows',
      [translationKeys.expandRow]: 'Expand current row',
      [translationKeys.collapseRow]: 'Collapse current row',
      */
      [translationKeys.selectAll]: 'Select all rows',
      [translationKeys.unselectAll]: 'Unselect all rows',
      [translationKeys.selectRow]: 'Select row',
      [translationKeys.unselectRow]: 'Unselect row',
    };
    
    const translateWithId = id => defaultTranslations[id];
  • TableBatchActions. Default implementation below:
    const translationKeys = {
      'carbon.table.batch.cancel': 'Cancel',
      'carbon.table.batch.items.selected': 'items selected',
      'carbon.table.batch.item.selected': 'item selected',
    };
    
    const translateWithId = (id, state) => {
      if (id === 'carbon.table.batch.cancel') {
        return translationKeys[id];
      }
      return `${state.totalSelected} ${translationKeys[id]}`;
    };
  • TableHeader for sort arrows, not currently used in dashboard tracked in Implement pagination and sorting method #842
  • ComboBox - passed to ListBox.Selection and ListBox.MenuIcon
  • Dropdown - passed to ListBox.MenuIcon
  • ListBoxMenuIcon
    export const translationIds = {
      'close.menu': 'close.menu',
      'open.menu': 'open.menu',
    };
    
    const defaultTranslations = {
      [translationIds['close.menu']]: 'Close menu',
      [translationIds['open.menu']]: 'Open menu',
    };
  • ListBoxSelection
    export const translationIds = {
      'clear.all': 'clear.all',
      'clear.selection': 'clear.selection',
    };
    
    const defaultTranslations = {
      [translationIds['clear.all']]: 'Clear all selected items',
      [translationIds['clear.selection']]: 'Clear selected item',
    };
@AlanGreene
Copy link
Member Author

we're nearly there

@AlanGreene
Copy link
Member Author

AlanGreene commented Mar 3, 2020

@steveodonovan pointed out that we missed some strings in the Carbon DataTable that don't follow the standard process of passing them as props, added details to the end of the description. There are likely others, doing a quick scan of the Carbon repo now and will update the description with other matches.

@AlanGreene
Copy link
Member Author

PR open for the last of the strings.

There are a few remaining strings that I've deliberately omitted:

  • 'key' and 'value' placeholders on Create PipelineRun and Create TaskRun label inputs
  • 'secret-name' placeholder on Create Secret (UniversalFields)
  • 'username' placeholder on Create Secret (PasswordType)

These inputs only accept a limited set of characters, so including translations here would likely confuse users.

We may revisit this in future to provide translated helper text or documentation in a user guide, but for now the placeholder values will remain untranslated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants