From b830c0f60e4e652564c3a90fe562ce0eee4965a2 Mon Sep 17 00:00:00 2001 From: Dessalines <tyhou13@gmx.com> Date: Thu, 25 Mar 2021 11:20:54 -0400 Subject: [PATCH] Some fixes. - Use ISO-630 library for native language names - Add sr-only to svg tooltips. Fixes #218 - Change support link and icon. --- package.json | 1 + src/shared/components/icon.tsx | 4 +- src/shared/components/navbar.tsx | 2 +- src/shared/components/person.tsx | 7 +++- src/shared/utils.ts | 69 ++++++++++++++++---------------- yarn.lock | 5 +++ 6 files changed, 49 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index e0047a2..3047b61 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "eslint": "^7.20.0", "eslint-plugin-prettier": "^3.3.1", "husky": "^5.1.0", + "iso-639-1": "^2.1.9", "lemmy-js-client": "0.10.0-rc.10", "lint-staged": "^10.5.4", "mini-css-extract-plugin": "^1.3.8", diff --git a/src/shared/components/icon.tsx b/src/shared/components/icon.tsx index b3ddab9..e3bd74a 100644 --- a/src/shared/components/icon.tsx +++ b/src/shared/components/icon.tsx @@ -13,7 +13,9 @@ export class Icon extends Component<IconProps, any> { render() { return ( <svg class={`icon ${this.props.classes}`}> - <title>{this.props.icon}</title> + <div class="sr-only"> + <title>{this.props.icon}</title> + </div> <use xlinkHref={`#icon-${this.props.icon}`}></use> </svg> ); diff --git a/src/shared/components/navbar.tsx b/src/shared/components/navbar.tsx index cedccb4..12a6ed2 100644 --- a/src/shared/components/navbar.tsx +++ b/src/shared/components/navbar.tsx @@ -262,7 +262,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> { title={i18n.t("support_lemmy")} href={supportLemmyUrl} > - <Icon icon="beer" classes="small" /> + <Icon icon="heart" classes="small" /> </a> </li> </ul> diff --git a/src/shared/components/person.tsx b/src/shared/components/person.tsx index fdc9479..b92c0ac 100644 --- a/src/shared/components/person.tsx +++ b/src/shared/components/person.tsx @@ -1,6 +1,7 @@ import { Component, linkEvent } from "inferno"; import { Link } from "inferno-router"; import { Subscription } from "rxjs"; +import ISO6391 from "iso-639-1"; import { UserOperation, SortType, @@ -536,8 +537,10 @@ export class Person extends Component<any, PersonState> { <option disabled aria-hidden="true"> ââ </option> - {languages.map(lang => ( - <option value={lang.code}>{lang.name}</option> + {languages.sort().map(lang => ( + <option value={lang.code}> + {ISO6391.getNativeName(lang.code) || lang.code} + </option> ))} </select> </div> diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 594cf40..363f810 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -78,7 +78,7 @@ export const favIconPngUrl = "/static/assets/apple-touch-icon.png"; // export const defaultFavIcon = `${window.location.protocol}//${window.location.host}${favIconPngUrl}`; export const repoUrl = "https://github.com/LemmyNet"; export const joinLemmyUrl = "https://join.lemmy.ml"; -export const supportLemmyUrl = "https://join.lemmy.ml/sponsors"; +export const supportLemmyUrl = "https://join.lemmy.ml/support"; export const docsUrl = "https://join.lemmy.ml/docs/en/index.html"; export const helpGuideUrl = "https://join.lemmy.ml/docs/en/about/guide.html"; // TODO find a way to redirect to the non-en folder export const markdownHelpUrl = `${helpGuideUrl}#markdown-guide`; @@ -91,39 +91,39 @@ export const fetchLimit = 20; export const mentionDropdownFetchLimit = 10; export const languages = [ - { code: "ca", name: "Català " }, - { code: "en", name: "English" }, - { code: "el", name: "Îλληνικά" }, - { code: "eu", name: "Euskara" }, - { code: "eo", name: "Esperanto" }, - { code: "es", name: "Español" }, - { code: "da", name: "Dansk" }, - { code: "de", name: "Deutsch" }, - { code: "ga", name: "Gaeilge" }, - { code: "gl", name: "Galego" }, - { code: "hr", name: "hrvatski" }, - { code: "hu", name: "Magyar Nyelv" }, - { code: "ka", name: "á¥áá áá£áá ááá" }, - { code: "ko", name: "íêµì´" }, - { code: "km", name: "áá¶áá¶ááááá" }, - { code: "hi", name: "मानठहिनà¥à¤¦à¥" }, - { code: "fa", name: "ÙارسÛ" }, - { code: "ja", name: "æ¥æ¬èª" }, - { code: "oc", name: "Occitan" }, - { code: "pl", name: "Polski" }, - { code: "pt_BR", name: "Português Brasileiro" }, - { code: "zh", name: "ä¸æ" }, - { code: "fi", name: "Suomi" }, - { code: "fr", name: "Français" }, - { code: "sv", name: "Svenska" }, - { code: "sq", name: "Shqip" }, - { code: "sr_Latn", name: "srpski" }, - { code: "th", name: "ภาษาà¹à¸à¸¢" }, - { code: "tr", name: "Türkçe" }, - { code: "uk", name: "УкÑаÑнÑÑка Mова" }, - { code: "ru", name: "Ð ÑÑÑкий" }, - { code: "nl", name: "Nederlands" }, - { code: "it", name: "Italiano" }, + { code: "ca" }, + { code: "en" }, + { code: "el" }, + { code: "eu" }, + { code: "eo" }, + { code: "es" }, + { code: "da" }, + { code: "de" }, + { code: "ga" }, + { code: "gl" }, + { code: "hr" }, + { code: "hu" }, + { code: "ka" }, + { code: "ko" }, + { code: "km" }, + { code: "hi" }, + { code: "fa" }, + { code: "ja" }, + { code: "oc" }, + { code: "pl" }, + { code: "pt_BR" }, + { code: "zh" }, + { code: "fi" }, + { code: "fr" }, + { code: "sv" }, + { code: "sq" }, + { code: "sr_Latn" }, + { code: "th" }, + { code: "tr" }, + { code: "uk" }, + { code: "ru" }, + { code: "nl" }, + { code: "it" }, ]; export const themes = [ @@ -381,7 +381,6 @@ export function getLanguage(override?: string): string { } } -// TODO export function getBrowserLanguage(): string { return navigator.language; } diff --git a/yarn.lock b/yarn.lock index 6f8a422..85fbab0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4833,6 +4833,11 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= +iso-639-1@^2.1.9: + version "2.1.9" + resolved "https://registry.yarnpkg.com/iso-639-1/-/iso-639-1-2.1.9.tgz#e41b11d4f1808e5316d0252c3fa16eeb9b37bb58" + integrity sha512-owRu9up+Cpx/hwSzm83j6G8PtC7U99UCtPVItsafefNfEgMl+pi8KBwhXwJkJfp6IouyYWFxj8n24SvCWpKZEQ== + isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" -- 2.44.1