Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update inlang.config.js #1243

Merged
merged 2 commits into from
Jan 27, 2023
Merged

update inlang.config.js #1243

merged 2 commits into from
Jan 27, 2023

Conversation

samuelstroschein
Copy link
Contributor

There were some breaking changes, see opral/monorepo#290. No further breaking changes are expected for the foreseeable future.

I also looked at finding a method to let users add new languages. Difficult. The day js files (https://github.com/osmosis-labs/osmosis-frontend/blob/master/packages/web/localizations/dayjs-locale-en.js) can not be generated via the editor. Adding new languages via the editor could creating new resources (de.json) etc. but the maintainers would still need to manually create the dayjs files + in the user store settings:

const SUPPORTED_LANGUAGES: MenuDropdownIconItemProps[] = [

Ideally, an i18n library (see opral/monorepo#289 (comment)) would deal with both problems automatically.

@vercel
Copy link

vercel bot commented Jan 21, 2023

@samuelstroschein is attempting to deploy a commit to the OsmoLabs Team on Vercel.

A member of the Team first needs to authorize it.

@ivanhofer
Copy link

@samuelstroschein inlang should probably not deal with altering other files. It could provide a hook onLocaleAdd inside inlang.config.js. Then each project could implement it's own logic.

inlang should probably also provide and manage an enum-like object of all available locales, so developers can e.g. write a switch-case statement, and TypeScript could throw an error if a locale does not get handled.

In this special case probably the easiest option is it to rewrite the code using the Intl.DateTimeFormat api:

const getLocalizedMonths = (locale: string) => {
	const monthFormatter = new Intl.DateTimeFormat(locale, { month: 'long' })
	return new Array(12).fill(0).map((_, i) => monthFormatter.format(new Date(0, i)))
}

const getLocalizedWeekdays = (locale: string) => {
	const weekdayFormatter = new Intl.DateTimeFormat(locale, { weekday: 'long' })
	return new Array(7).fill(0).map((_, i) => weekdayFormatter.format(new Date(1, 0, i)))
}

console.log(getLocalizedMonths('en'))
console.log(getLocalizedWeekdays('en'))

output:
image

@vercel
Copy link

vercel bot commented Jan 22, 2023

Deployment failed with the following error:

Was unable to schedule a deployment.

@samuelstroschein
Copy link
Contributor Author

@ivanhofer

inlang should probably not deal with altering other files.

Absolutely agree. I was referring to an i18n library that deals with altering files based on the inlang.config.js file but inlang would not do it itself.

inlang should probably also provide and manage an enum-like object of all available locales

The config already provides config.languages that could be used. But ... to access the languages, the defineConfig function needs to be called, probably without dynamically importing plugins or dependencies.

@jonator jonator changed the base branch from master to stage January 27, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants