mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-07 10:32:50 -06:00
Compare commits
1 Commits
feat/css-v
...
chore/remo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
626b40e070 |
@@ -54,7 +54,6 @@
|
||||
"devDependencies": {
|
||||
"@formbricks/config-typescript": "workspace:*",
|
||||
"@formbricks/eslint-config": "workspace:*",
|
||||
"@formbricks/i18n-utils": "workspace:*",
|
||||
"@formbricks/types": "workspace:*",
|
||||
"@preact/preset-vite": "2.10.1",
|
||||
"@tailwindcss/postcss": "4.1.17",
|
||||
@@ -70,4 +69,4 @@
|
||||
"vite-plugin-dts": "4.5.3",
|
||||
"vite-tsconfig-paths": "5.1.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useRef, useState } from "preact/hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getLanguageLabel } from "@formbricks/i18n-utils/src";
|
||||
import { TJsEnvironmentStateSurvey } from "@formbricks/types/js";
|
||||
import { type TSurveyLanguage } from "@formbricks/types/surveys/types";
|
||||
import { LanguageIcon } from "@/components/icons/language-icon";
|
||||
import { mixColor } from "@/lib/color";
|
||||
import { getLanguageDisplayName } from "@/lib/get-language-display-name";
|
||||
import { getI18nLanguage } from "@/lib/i18n-utils";
|
||||
import i18n from "@/lib/i18n.config";
|
||||
import { useClickOutside } from "@/lib/use-click-outside-hook";
|
||||
@@ -80,7 +80,7 @@ export function LanguageSwitch({
|
||||
title={t("common.language_switch")}
|
||||
type="button"
|
||||
className={cn(
|
||||
"text-heading relative flex h-8 w-8 items-center justify-center rounded-md focus:ring-2 focus:ring-offset-2 focus:outline-hidden"
|
||||
"text-heading focus:outline-hidden relative flex h-8 w-8 items-center justify-center rounded-md focus:ring-2 focus:ring-offset-2"
|
||||
)}
|
||||
style={{
|
||||
backgroundColor: isHovered ? hoverColorWithOpacity : "transparent",
|
||||
@@ -113,7 +113,7 @@ export function LanguageSwitch({
|
||||
onClick={() => {
|
||||
changeLanguage(surveyLanguage.language.code);
|
||||
}}>
|
||||
{getLanguageLabel(surveyLanguage.language.code, "en-US")}
|
||||
{getLanguageDisplayName(surveyLanguage.language.code)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
|
||||
14
packages/surveys/src/lib/get-language-display-name.ts
Normal file
14
packages/surveys/src/lib/get-language-display-name.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Returns the display name for a language code using Intl.DisplayNames (built-in, 0 KB).
|
||||
* Falls back to the code if the API is unavailable or the tag is unknown.
|
||||
*/
|
||||
export function getLanguageDisplayName(code: string): string {
|
||||
if (typeof Intl === "undefined" || !Intl.DisplayNames) return code;
|
||||
try {
|
||||
const displayNames = new Intl.DisplayNames(["en-US"], { type: "language" });
|
||||
const name = displayNames.of(code);
|
||||
return name && name !== code ? name : code;
|
||||
} catch {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -999,9 +999,6 @@ importers:
|
||||
'@formbricks/eslint-config':
|
||||
specifier: workspace:*
|
||||
version: link:../config-eslint
|
||||
'@formbricks/i18n-utils':
|
||||
specifier: workspace:*
|
||||
version: link:../i18n-utils
|
||||
'@formbricks/types':
|
||||
specifier: workspace:*
|
||||
version: link:../types
|
||||
@@ -7663,6 +7660,7 @@ packages:
|
||||
|
||||
glob@10.5.0:
|
||||
resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
hasBin: true
|
||||
|
||||
glob@11.1.0:
|
||||
@@ -7672,7 +7670,7 @@ packages:
|
||||
|
||||
glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
deprecated: Glob versions prior to v9 are no longer supported
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
globals@13.24.0:
|
||||
resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==}
|
||||
|
||||
Reference in New Issue
Block a user