Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Humanize spell check language labels (#12409)
Browse files Browse the repository at this point in the history
* Humanize spell check language labels

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Comment

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy authored Apr 10, 2024
1 parent d35fce1 commit c40fea0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/views/settings/SpellCheckSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ import React from "react";

import SpellCheckLanguagesDropdown from "../../../components/views/elements/SpellCheckLanguagesDropdown";
import AccessibleButton, { ButtonEvent } from "../../../components/views/elements/AccessibleButton";
import { _t } from "../../../languageHandler";
import { _t, getUserLanguage } from "../../../languageHandler";

interface ExistingSpellCheckLanguageIProps {
language: string;
/**
* The label to render on the component. If not provided, the language code will be used.
*/
label?: string;
onRemoved(language: string): void;
}

Expand All @@ -45,7 +49,9 @@ export class ExistingSpellCheckLanguage extends React.Component<ExistingSpellChe
public render(): React.ReactNode {
return (
<div className="mx_ExistingSpellCheckLanguage">
<span className="mx_ExistingSpellCheckLanguage_language">{this.props.language}</span>
<span className="mx_ExistingSpellCheckLanguage_language">
{this.props.label ?? this.props.language}
</span>
<AccessibleButton onClick={this.onRemove} kind="danger_sm">
{_t("action|remove")}
</AccessibleButton>
Expand Down Expand Up @@ -87,8 +93,9 @@ export default class SpellCheckLanguages extends React.Component<SpellCheckLangu
};

public render(): React.ReactNode {
const intl = new Intl.DisplayNames([getUserLanguage()], { type: "language", style: "short" });
const existingSpellCheckLanguages = this.props.languages.map((e) => {
return <ExistingSpellCheckLanguage language={e} onRemoved={this.onRemoved} key={e} />;
return <ExistingSpellCheckLanguage language={e} label={intl.of(e)} onRemoved={this.onRemoved} key={e} />;
});

const addButton = (
Expand Down

0 comments on commit c40fea0

Please sign in to comment.