Add translations for profile page (#1340)

Co-authored-by: Sasha Sorokin <10401817+brawaru@users.noreply.github.com>
This commit is contained in:
Mysterious_Dev
2023-09-02 15:37:04 +02:00
committed by GitHub
parent 9895976128
commit 75e075ef8e
6 changed files with 379 additions and 32 deletions

34
utils/common-messages.ts Normal file
View File

@@ -0,0 +1,34 @@
export const commonMessages = defineMessages({
allProjectType: {
id: 'project-type.all',
defaultMessage: 'All',
},
cancelButton: {
id: 'button.cancel',
defaultMessage: 'Cancel',
},
editButton: {
id: 'button.edit',
defaultMessage: 'Edit',
},
galleryInputView: {
id: 'input.view.gallery',
defaultMessage: 'Gallery view',
},
gridInputView: {
id: 'input.view.grid',
defaultMessage: 'Grid view',
},
listInputView: {
id: 'input.view.list',
defaultMessage: 'List view',
},
errorNotificationTitle: {
id: 'notification.error.title',
defaultMessage: 'An error occurred',
},
saveButton: {
id: 'button.save',
defaultMessage: 'Save',
},
})

View File

@@ -0,0 +1,58 @@
const projectTypeMessages = defineMessages({
datapack: {
id: 'project-type.datapack.singular',
defaultMessage: 'Data Pack',
},
datapacks: {
id: 'project-type.datapack.plural',
defaultMessage: 'Data Packs',
},
mod: {
id: 'project-type.mod.singular',
defaultMessage: 'Mod',
},
mods: {
id: 'project-type.mod.plural',
defaultMessage: 'Mods',
},
modpack: {
id: 'project-type.modpack.singular',
defaultMessage: 'Modpack',
},
modpacks: {
id: 'project-type.modpack.plural',
defaultMessage: 'Modpacks',
},
plugin: {
id: 'project-type.plugin.singular',
defaultMessage: 'Plugin',
},
plugins: {
id: 'project-type.plugin.plural',
defaultMessage: 'Plugins',
},
resourcepack: {
id: 'project-type.resourcepack.singular',
defaultMessage: 'Resource Pack',
},
resourcepacks: {
id: 'project-type.resourcepack.plural',
defaultMessage: 'Resource Packs',
},
shader: {
id: 'project-type.shader.singular',
defaultMessage: 'Shader',
},
shaders: {
id: 'project-type.shader.plural',
defaultMessage: 'Shaders',
},
})
type ExtractSingulars<K extends string> = K extends `${infer T}s` ? T : never
type ProjectType = ExtractSingulars<keyof typeof projectTypeMessages>
export function getProjectTypeMessage(type: ProjectType, plural = false) {
return projectTypeMessages[`${type}${plural ? 's' : ''}`]
}

25
utils/vue-children.ts Normal file
View File

@@ -0,0 +1,25 @@
import { createTextVNode, isVNode, toDisplayString, type VNode } from 'vue'
/**
* Checks whether a specific child is a VNode. If not, converts it to a display
* string and then creates text VNode for the result.
*
* @param child Child to normalize.
* @returns Either the original VNode or a text VNode containing child converted
* to a display string.
*/
function normalizeChild(child: any): VNode {
return isVNode(child) ? child : createTextVNode(toDisplayString(child))
}
/**
* Takes in an array of VNodes and other children. It then converts each child
* that is not already a VNode to a display string, and creates a text VNode for
* that string.
*
* @param children Children to normalize.
* @returns Children with all of non-VNodes converted to display strings.
*/
export function normalizeChildren(children: any | any[]): VNode[] {
return Array.isArray(children) ? children.map(normalizeChild) : [normalizeChild(children)]
}