헤더 로케일 선택기

:information_source: 요약 **헤더 로케일 선택기(Header Locale Selector)**는 사이트 헤더에 사용자를 위한 언어 선택기를 추가합니다.
:eyeglasses: 미리보기 theme-creator.discourse.org에서 미리보기
:hammer_and_wrench: 저장소 링크 GitHub - Ahmedgagan/header-locale-selector · GitHub
:open_book: 디스코urs 테마 초보자? 디스코urs 테마 사용 입문가이드

이 테마 컴포넌트 설치

이 테마 컴포넌트는 사이트 헤더에 사용 가능한 언어 드롭다운 메뉴를 추가합니다. 사이트의 기본 언어에 익숙하지 않은 사용자에게 매우 유용합니다.

참고: 이 기능은 로그인한 사용자에게만 제공됩니다.

스폰서

이 컴포넌트의 스폰서를 맡아주신 @Richard_Millington님께 특별한 감사의 말씀을 드립니다.

13개의 좋아요

Having this be more prominent & including flags could really help people on multi-language forums.

Awesome addition to the ecosystem. :+1:

5개의 좋아요

This is an amazing fantastic feature! It is my recommendation the Team should consider adding this component minimally as a pre installed theme-component in core!

Thank you very kindly for releasing this!
:vulcan_salute::star_struck::+1:

2개의 좋아요

I have small feature request.

Would it be possible to have drop down link able to adjust on mobile?

If I enable the chat plugin it is going to be very crowded. Perhaps even have it configurable to use flags on Desktop with mobile using the 2 letters similar to wasvit earlier windows? Been Awhile. lol

Though scaling might work to be similar on size as the search mag glass

Just s9me feedback from one of members.

Great component

the selection of languages with the flags is cool, unfortunately contains some errors. Croatia has not received a flag.
Catalonia is a part of Spain.


Also can you share sime code to reduce flag size on Mobile?

Would it be possible to have an option to use the country code instead of the flags? Similar to keyboard language on Windows.l?

ie en es etc.. The flag is huge on mobile. Or an option to shrink the flag size.

Even a css overide would be handy. Thanks

1개의 좋아요

Yes, this switch needs to be modified to match the general style of discourse. He’s terrible now

1개의 좋아요

Screenshots of the current appearance for reference:

Desktop:

Mobile:

This component does not work for me. Is there anything else to do besides turning it on and selecting a template?

It needs at least a partial rework. If someone want to contribute and send PRs to fix various things, it’s welcomed :slight_smile:

1개의 좋아요

Tagged as broken for now

The component is broken, but marked as compatible with the latest version
https://github.com/discourse/discourse-locale-switcher/commit/52ec812157d4d3ffec2a5de9eb4cc4a5e2476cae

@volanar That’s not the same component.

1개의 좋아요

I’m removing the broken tag.

To begin with, the component was never broken!
There was a misunderstanding about another Discourse theme component that Volanar reported as broken.

I tested the component, which still works on the latest Discourse version.
However, it still requires some updates to modernize it, resolve a deprecation, and fix minor issues so it will work well on the latest Discourse version.

I went ahead and I made a PR (sponsored by @Richard_Millington) :+1:
https://github.com/Ahmedgagan/header-locale-selector/pull/3

6개의 좋아요

The PR has been merged; thanks, Ahmed. :+1:

4개의 좋아요

how use 2 or 3 lang and remove others lang ?
btw i optimized code for locale-selector.js:

import Component from "@ember/component";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import { userPath } from "discourse/lib/url";
import { isTesting } from "discourse-common/config/environment";

export default class LocaleSelector extends Component {
  @service currentUser;

  get availableLocales() {
    // Cache filtered locales for performance optimization
    if (!this._filteredLocales) {
      const allLocales = JSON.parse(this.siteSettings.available_locales);
      this._filteredLocales = allLocales.filter(locale => ['en', 'ar'].includes(locale));
    }
    return this._filteredLocales;
  }

  @action
  onChangeLocale(value) {
    this.set("currentUser.locale", value);
    ajax(userPath(`${this.currentUser.username_lower}.json`), {
      data: { locale: this.currentUser.locale },
      type: "PUT",
    }).then(() => {
      if (!isTesting()) {
        location.reload();
      }
    });
  }

  defaultItem() {
    const currentUserLocale = document.documentElement
      .getAttribute("lang")
      ?.replaceAll("-", "_");

    return (
      this.content.find((val) => val.value === currentUserLocale) ||
      this.content.find((val) => val.value === this.siteSettings.default_locale)
    );
  }
}

after test it discourse keeping freeze
any idea?

available_locales has this structure:

[
  {
    name: "English (US)",
    value: "en"
  },
  ...
] 

So in your code you will need to use locale.value. :+1:

@Ahmed_Gagan 이 테마 컴포넌트에 새로운 문제가 있는 것 같습니다:

여기서 참고할 점으로, 이 테마 구성 요소는 더 이상 필요하지 않으며, 위에서 나열된 사이트 설정에서 코어에 의해 지원됩니다. (문서)