Skip to content

Commit

Permalink
Merge pull request #2563 from opral/run-pretier-on-paraglide
Browse files Browse the repository at this point in the history
apply prettier on the repo - affected: paraglidejs and editor
  • Loading branch information
LorisSigrist authored Apr 11, 2024
2 parents cec4350 + a6daa49 commit 83d37f8
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 69 deletions.
22 changes: 14 additions & 8 deletions inlang/source-code/editor/src/interface/editor/EditorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ function EditorHeader() {
(user()?.isLoggedIn && "mr-14")
}
>
<Button type="text" class="hidden sm:flex"
href={import.meta.env.PROD
? "https://inlang.com/c/lint-rules"
: "http://localhost:3000/c/lint-rules"}>
<Button
type="text"
class="hidden sm:flex"
href={
import.meta.env.PROD
? "https://inlang.com/c/lint-rules"
: "http://localhost:3000/c/lint-rules"
}
>
Find Lint Rules
</Button>
<sl-dropdown prop:placement="bottom-end" class="peer">
<button slot="trigger" class="flex pointer-events-auto justify-center items-center h-10 relative gap-2 rounded-md flex-grow-0 flex-shrink-0 text-sm font-medium text-left cursor-pointer transition-all duration-200 text-surface-700 hover:text-primary">
<button
slot="trigger"
class="flex pointer-events-auto justify-center items-center h-10 relative gap-2 rounded-md flex-grow-0 flex-shrink-0 text-sm font-medium text-left cursor-pointer transition-all duration-200 text-surface-700 hover:text-primary"
>
Need Help?
</button>
<sl-menu class="w-fit">
Expand All @@ -73,9 +81,7 @@ function EditorHeader() {
{link.name}
</a>
</sl-menu-item>
<Show
when={link.name === "About the ecosystem"}
>
<Show when={link.name === "About the ecosystem"}>
<div class="w-full border-b border-surface-200 my-1" />
</Show>
</>
Expand Down
6 changes: 2 additions & 4 deletions inlang/source-code/editor/src/interface/editor/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const getFinkResourcesLinks = () => {
{
name: "Submit Feedback",
href: "https://github.com/orgs/opral/discussions/categories/-fink-general",
}
},
]
}

Expand Down Expand Up @@ -99,9 +99,7 @@ const Footer = () => {
{link.name}
</a>
</sl-menu-item>
<Show
when={link.name === "About the ecosystem"}
>
<Show when={link.name === "About the ecosystem"}>
<div class="w-full border-b border-surface-200 my-1" />
</Show>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
defaultLanguageTag: i18n.config.defaultLanguageTag,
})
const translatedPath = getTranslatedPath(canonicalPath, language, i18n.config.translations, i18n.config.matchers)
const translatedPath = getTranslatedPath(
canonicalPath,
language,
i18n.config.translations,
i18n.config.matchers,
)
const newPathname = serializeRoute({
base: absoluteBase,
Expand Down Expand Up @@ -102,14 +107,18 @@
<!-- If there is more than one language, add alternate links -->
{#if i18n.config.runtime.availableLanguageTags.length >= 1}
{#each i18n.config.runtime.availableLanguageTags as lang}
{@const path = translatePath($page.url.pathname, lang, i18n.config.translations,
i18n.config.matchers,
{
base: absoluteBase,
availableLanguageTags: i18n.config.runtime.availableLanguageTags,
defaultLanguageTag: i18n.config.defaultLanguageTag,
prefixDefaultLanguage: i18n.config.prefixDefaultLanguage,
})}
{@const path = translatePath(
$page.url.pathname,
lang,
i18n.config.translations,
i18n.config.matchers,
{
base: absoluteBase,
availableLanguageTags: i18n.config.runtime.availableLanguageTags,
defaultLanguageTag: i18n.config.defaultLanguageTag,
prefixDefaultLanguage: i18n.config.prefixDefaultLanguage,
},
)}

{@const href =
$page.url.host === "sveltekit-prerender" ? path : new URL(path, new URL($page.url)).href}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ export type I18nConfig<T extends string> = {
export function createI18n<T extends string>(runtime: Paraglide<T>, options?: I18nUserConfig<T>) {
const translations = resolvePathTranslations(
options?.pathnames ?? {},
runtime.availableLanguageTags
runtime.availableLanguageTags,
)

if (dev) {
const issues = validatePathTranslations(
translations,
runtime.availableLanguageTags,
options?.matchers ?? {}
options?.matchers ?? {},
)
if (issues.length) {
console.warn(
`The following issues were found in your path translations. Make sure to fix them before deploying your app:`
`The following issues were found in your path translations. Make sure to fix them before deploying your app:`,
)
console.table(issues)
}
Expand Down Expand Up @@ -270,7 +270,7 @@ export function createI18n<T extends string>(runtime: Paraglide<T>, options?: I1
canonicalPath,
lang,
config.translations,
config.matchers
config.matchers,
)

return serializeRoute({
Expand Down Expand Up @@ -304,7 +304,6 @@ export function createI18n<T extends string>(runtime: Paraglide<T>, options?: I1
* ```
*/
route(translatedPath: string) {

const normalizedBase = normaliseBase(base)

const { path, lang, trailingSlash, dataSuffix } = getPathInfo(translatedPath, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result).toEqual([])
})
Expand All @@ -26,7 +26,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(1)
})
Expand All @@ -40,7 +40,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(1)
})
Expand All @@ -54,7 +54,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(1)
})
Expand All @@ -68,7 +68,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(1)
})
Expand All @@ -82,7 +82,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(0)
})
Expand All @@ -99,7 +99,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(0)
})
Expand All @@ -113,7 +113,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(1)
})
Expand All @@ -127,7 +127,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(0)
})
Expand All @@ -144,7 +144,7 @@ describe("validatePathTranslations", () => {
{
int: () => true,
float: () => true,
}
},
)
expect(result.length).toBe(1)
})
Expand All @@ -158,7 +158,7 @@ describe("validatePathTranslations", () => {
},
},
["en", "de"],
{}
{},
)
expect(result.length).toBe(1)
})
Expand All @@ -175,7 +175,7 @@ describe("validatePathTranslations", () => {
{
int: () => true,
float: () => true,
}
},
)
expect(result.length).toBe(0)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type PathTranslationIssue = {
export function validatePathTranslations<T extends string>(
pathTranslations: PathTranslations<T>,
availableLanguageTags: readonly T[],
matchers: Record<string, ParamMatcher>
matchers: Record<string, ParamMatcher>,
): PathTranslationIssue[] {
const issues: PathTranslationIssue[] = []

Expand Down Expand Up @@ -90,7 +90,7 @@ export function validatePathTranslations<T extends string>(
issues.push({
path,
message: `The following languages are missing translations: ${[...missingLanguages].join(
", "
", ",
)}`,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { PathTranslations } from "../config/pathTranslations.js"
export const handleRedirects: (
runtime: Paraglide<any>,
translations: PathTranslations<string>,
matchers: Record<string, ParamMatcher>
matchers: Record<string, ParamMatcher>,
) => Handle =
(runtime, translations, matchers) =>
async ({ event, resolve }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("getCanonicalPath", () => {
de: "/uber-uns",
},
},
{}
{},
)
expect(translatedPath).toBe("/")
})
Expand All @@ -41,7 +41,7 @@ describe("getCanonicalPath", () => {
de: "/baz",
},
},
{}
{},
)
expect(canonicalPath).toBe("/foo")
})
Expand All @@ -61,7 +61,7 @@ describe("getCanonicalPath", () => {
de: "/baz/[id]/[slug]",
},
},
{}
{},
)
expect(canonicalPath).toBe("/foo/123")
})
Expand All @@ -81,7 +81,7 @@ describe("getCanonicalPath", () => {
de: "/baz/[id]/[slug]",
},
},
{}
{},
)
expect(canonicalPath).toBe("/foo/123")
})
Expand All @@ -96,7 +96,7 @@ describe("getCanonicalPath", () => {
de: "/baz/[...rest]",
},
},
{}
{},
)
expect(canonicalPath).toBe("/foo/123/baz")
})
Expand All @@ -111,7 +111,7 @@ describe("getCanonicalPath", () => {
de: "/baz/[...rest]",
},
},
{}
{},
)
expect(canonicalPath).toBe("/foo")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getCanonicalPath(
translatedPath: string,
lang: string,
translations: PathTranslations,
matchers: Record<string, ParamMatcher>
matchers: Record<string, ParamMatcher>,
): string {
for (const [canonicalPathDefinition, translationsForPath] of Object.entries(translations)) {
if (!(lang in translationsForPath)) continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("getTranslatedPath", () => {
de: "/baz",
},
},
{}
{},
)
expect(translatedPath).toBe("/bar")
})
Expand All @@ -32,7 +32,7 @@ describe("getTranslatedPath", () => {
de: "/baz/[id]/cvb",
},
},
{}
{},
)
expect(translatedPath).toBe("/bar/123/cvb")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function getTranslatedPath(
canonicalPath: string,
lang: string,
translations: PathTranslations,
matchers: Record<string, ParamMatcher>
matchers: Record<string, ParamMatcher>,
) {
const match = bestMatch(canonicalPath, Object.keys(translations), matchers)
if (!match) return canonicalPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { exec, parse_route_id } from "./routing.js"
export function bestMatch(
canonicalPath: string,
pathDefinitions: string[],
matchers: Record<string, ParamMatcher>
matchers: Record<string, ParamMatcher>,
): { params: Record<string, string>; id: string } | undefined {
let bestMatch:
| {
Expand Down Expand Up @@ -57,10 +57,10 @@ export function bestMatch(
? {
id: bestMatch.id,
params: bestMatch.params,
}
}
: undefined
}

function removeTrailingSlash(path: string): string {
return path.endsWith("/") ? path.slice(0, -1) : path
}
}
Loading

0 comments on commit 83d37f8

Please sign in to comment.