mirror of
https://github.com/pretix/pretix.git
synced 2026-11-24 03:31:55 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3ce54d51d | ||
|
|
e4592d7132 |
No files matched your search
@@ -43,8 +43,6 @@ const ignores = globalIgnores([
|
||||
'src/pretix/static/pretixbase/js/addressform.js',
|
||||
'src/pretix/static/pretixbase/js/asynctask.js',
|
||||
'src/pretix/static/pretixbase/js/details.js',
|
||||
'src/pretix/static/pretixbase/js/gettextstub.js',
|
||||
'src/pretix/static/pretixbase/js/i18nstring.js',
|
||||
'src/pretix/static/pretixcontrol/js/menu.js',
|
||||
'src/pretix/static/pretixcontrol/js/ui/editor.js',
|
||||
'src/pretix/static/pretixcontrol/js/ui/geo.js',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { I18nString, SubEvent } from './i18n'
|
||||
import type { SubEvent } from './i18n'
|
||||
import type { LocalizableString } from '@/pretix/static/pretixbase/js/i18n'
|
||||
|
||||
const settingsEl = document.getElementById('api-settings')
|
||||
const { urls } = JSON.parse(settingsEl.textContent || '{}') as { urls: {
|
||||
@@ -59,8 +60,8 @@ export interface Position {
|
||||
order: string
|
||||
positionid: number
|
||||
canceled?: boolean
|
||||
item: { id?: number; name: I18nString; internal_name?: string; admission?: boolean }
|
||||
variation: { id?: number; value: I18nString } | null
|
||||
item: { id?: number; name: LocalizableString; internal_name?: string; admission?: boolean }
|
||||
variation: { id?: number; value: LocalizableString } | null
|
||||
price: string
|
||||
attendee_name: string
|
||||
attendee_name_parts: Record<string, string>
|
||||
@@ -110,8 +111,8 @@ export interface Answer {
|
||||
|
||||
export interface AnswerQuestion {
|
||||
id: number
|
||||
question: I18nString
|
||||
help_text?: I18nString
|
||||
question: LocalizableString
|
||||
help_text?: LocalizableString
|
||||
type: string
|
||||
required: boolean
|
||||
position: number
|
||||
@@ -138,12 +139,12 @@ export interface QuestionOption {
|
||||
id: number
|
||||
identifier: string
|
||||
position: number
|
||||
answer: I18nString
|
||||
answer: LocalizableString
|
||||
}
|
||||
|
||||
export interface Addon {
|
||||
item: { name: I18nString; internal_name?: string }
|
||||
variation: { value: I18nString } | null
|
||||
item: { name: LocalizableString; internal_name?: string }
|
||||
variation: { value: LocalizableString } | null
|
||||
}
|
||||
|
||||
export interface CheckinStatusVariation {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import { ref, computed, nextTick, onMounted, onUnmounted } from 'vue'
|
||||
import { api } from '../api'
|
||||
import type { CheckinList, Position, RedeemResponse, CheckinStatus, AnswerQuestion } from '../api'
|
||||
import { STRINGS, i18nstringLocalize, formatSubevent, formatAnswer } from '../i18n'
|
||||
import { STRINGS, formatSubevent, formatAnswer } from '../i18n'
|
||||
import { localize_string } from '@/pretix/static/pretixbase/js/i18n'
|
||||
|
||||
import CheckinlistSelect from './checkinlist-select.vue'
|
||||
import SearchresultItem from './searchresult-item.vue'
|
||||
@@ -114,9 +115,9 @@ const checkResultAddons = computed(() => {
|
||||
if (!checkResult.value?.position?.addons) return ''
|
||||
return checkResult.value.position.addons.map((addon) => {
|
||||
if (addon.variation) {
|
||||
return `+ ${addon.item.internal_name || i18nstringLocalize(addon.item.name)} – ${i18nstringLocalize(addon.variation.value)}`
|
||||
return `+ ${addon.item.internal_name || localize_string(addon.item.name)} – ${localize_string(addon.variation.value)}`
|
||||
}
|
||||
return '+ ' + (addon.item.internal_name || i18nstringLocalize(addon.item.name))
|
||||
return '+ ' + (addon.item.internal_name || localize_string(addon.item.name))
|
||||
}).join('\n')
|
||||
})
|
||||
|
||||
@@ -125,9 +126,9 @@ const checkResultSubevent = computed(() => formatSubevent(checkResult.value?.pos
|
||||
const checkResultItemvar = computed(() => {
|
||||
if (!checkResult.value?.position) return ''
|
||||
if (checkResult.value.position.variation) {
|
||||
return `${i18nstringLocalize(checkResult.value.position.item.name)} – ${i18nstringLocalize(checkResult.value.position.variation.value)}`
|
||||
return `${localize_string(checkResult.value.position.item.name)} – ${localize_string(checkResult.value.position.variation.value)}`
|
||||
}
|
||||
return i18nstringLocalize(checkResult.value.position.item.name)
|
||||
return localize_string(checkResult.value.position.item.name)
|
||||
})
|
||||
|
||||
const checkResultText = computed(() => {
|
||||
@@ -316,9 +317,9 @@ async function check (
|
||||
if (!answers.value[q.id.toString()]) {
|
||||
answers.value[q.id.toString()] = ''
|
||||
}
|
||||
;(q as AnswerQuestion).question = i18nstringLocalize(q.question)
|
||||
;(q as AnswerQuestion).question = localize_string(q.question)
|
||||
for (const o of q.options) {
|
||||
;(o as { answer: string }).answer = i18nstringLocalize(o.answer)
|
||||
;(o as { answer: string }).answer = localize_string(o.answer)
|
||||
}
|
||||
}
|
||||
nextTick(() => {
|
||||
@@ -410,7 +411,7 @@ onUnmounted(() => {
|
||||
span(v-for="a in checkResult.position.answers")
|
||||
span(v-if="a.question.show_during_checkin")
|
||||
br
|
||||
strong {{ i18nstringLocalize(a.question.question) }}:
|
||||
strong {{ localize_string(a.question.question) }}:
|
||||
| {{ formatAnswer(a.answer, a.question) }}
|
||||
strong(v-for="t in checkResult.checkin_texts")
|
||||
br
|
||||
|
||||
+4
-3
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import type { Position } from '../api'
|
||||
import { STRINGS, i18nstringLocalize, formatSubevent } from '../i18n'
|
||||
import { STRINGS, formatSubevent } from '../i18n'
|
||||
import { localize_string } from '@/pretix/static/pretixbase/js/i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
position: Position
|
||||
@@ -22,9 +23,9 @@ const status = computed(() => {
|
||||
|
||||
const itemvar = computed(() => {
|
||||
if (props.position.variation) {
|
||||
return `${i18nstringLocalize(props.position.item.name)} – ${i18nstringLocalize(props.position.variation.value)}`
|
||||
return `${localize_string(props.position.item.name)} – ${localize_string(props.position.variation.value)}`
|
||||
}
|
||||
return i18nstringLocalize(props.position.item.name)
|
||||
return localize_string(props.position.item.name)
|
||||
})
|
||||
|
||||
const subevent = computed(() => formatSubevent(props.position.subevent))
|
||||
|
||||
@@ -9,27 +9,6 @@ export const pretixLocale = body.dataset.pretixlocale ?? 'en'
|
||||
|
||||
moment.locale(datetimeLocale)
|
||||
|
||||
export function gettext (msgid: string): string {
|
||||
if (typeof django !== 'undefined' && typeof django.gettext !== 'undefined') {
|
||||
return django.gettext(msgid)
|
||||
}
|
||||
return msgid
|
||||
}
|
||||
|
||||
export function ngettext (singular: string, plural: string, count: number): string {
|
||||
if (typeof django !== 'undefined' && typeof django.ngettext !== 'undefined') {
|
||||
return django.ngettext(singular, plural, count)
|
||||
}
|
||||
return plural
|
||||
}
|
||||
|
||||
export type I18nString = string | Record<string, string> | null | undefined
|
||||
|
||||
export function i18nstringLocalize (obj: I18nString): string {
|
||||
// external
|
||||
return i18nstring_localize(obj)
|
||||
}
|
||||
|
||||
export const STRINGS: Record<string, string> = {
|
||||
'checkinlist.select': gettext('Select a check-in list'),
|
||||
'checkinlist.none': gettext('No active check-in lists found.'),
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
data-pretixlocale="{{ request.LANGUAGE_CODE }}" data-timezone="{{ request.event.settings.timezone }}">
|
||||
<div id="app" data-event-name="{{ request.event.name }}"></div>
|
||||
{% compress js %}
|
||||
<script type="text/javascript" src="{% static "pretixbase/js/i18nstring.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "moment/moment-with-locales.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "moment/moment-timezone-with-data-1970-2030.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "jquery/js/jquery-3.6.4.min.js" %}"></script>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import { watchEffect } from 'vue'
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
placeholders?: Record<string, string>;
|
||||
locales: Record<string, string>;
|
||||
errors?: string[];
|
||||
multiline?: boolean;
|
||||
}>()
|
||||
|
||||
const modelValue = defineModel<Record<string, string> | string>({ default: () => ({}) })
|
||||
|
||||
watchEffect(() => {
|
||||
if (typeof modelValue.value === 'string') {
|
||||
const oldVal = modelValue.value
|
||||
modelValue.value = Object.fromEntries(
|
||||
Object.keys(props.locales).map((x): [string, string] => [x, oldVal]),
|
||||
)
|
||||
}
|
||||
|
||||
const additionalLocales = new Set(Object.keys(modelValue.value)).difference(new Set(Object.keys(props.locales)))
|
||||
for (const additionalLocale of additionalLocales) {
|
||||
delete modelValue.value[additionalLocale]
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template lang="pug">
|
||||
template(v-if="!!modelValue")
|
||||
component.form-control(
|
||||
:is="multiline ? 'textarea' : 'input'"
|
||||
v-for="(human_readable, locale) in locales"
|
||||
v-bind="$attrs"
|
||||
:key="locale"
|
||||
:lang="locale"
|
||||
:title="human_readable"
|
||||
:placeholder="placeholders?.[locale] || human_readable"
|
||||
:value="modelValue[locale]"
|
||||
@input="event => modelValue[locale] = event.target.value"
|
||||
)
|
||||
template(v-if="!!errors")
|
||||
.help-block(v-for="error in errors") {{ error }}
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
export type LocalizableString = null | string | Record<string, string>;
|
||||
|
||||
export function localize_string(s: LocalizableString, locale?: string): string {
|
||||
if (typeof s === "string") {
|
||||
return s;
|
||||
}
|
||||
if (s === null) {
|
||||
return null;
|
||||
}
|
||||
if (!locale) {
|
||||
locale = document.body.attributes["data-pretixlocale"].value;
|
||||
}
|
||||
var short_locale = locale.split("-")[0];
|
||||
if (locale in s) return s[locale];
|
||||
|
||||
if (short_locale in s) return s[short_locale];
|
||||
|
||||
for (const k of Object.keys(s)) {
|
||||
if (k.split("-")[0] === short_locale && s[k]) {
|
||||
return s[k];
|
||||
}
|
||||
}
|
||||
|
||||
if (s["en"]) return s["en"];
|
||||
|
||||
for (const k of Object.keys(s)) {
|
||||
if (s[k]) {
|
||||
return s[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
function i18nstring_localize (o) {
|
||||
let locale = document.body.attributes['data-pretixlocale'].value
|
||||
let short_locale = locale.split('-')[0]
|
||||
if (o[locale])
|
||||
return o[locale]
|
||||
|
||||
if (o[short_locale])
|
||||
return o[short_locale]
|
||||
|
||||
for (let k of Object.keys(o)) {
|
||||
if (k.split('-')[0] === short_locale && o[k]) {
|
||||
return o[k]
|
||||
}
|
||||
}
|
||||
|
||||
if (o['en'])
|
||||
return o['en']
|
||||
|
||||
for (let k of Object.keys(o)) {
|
||||
if (o[k]) {
|
||||
return o[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
/* global gettext, pgettext */
|
||||
|
||||
export const TEXTS = {
|
||||
and: gettext('All of the conditions below (AND)'),
|
||||
or: gettext('At least one of the conditions below (OR)'),
|
||||
|
||||
+3
-1
@@ -7,7 +7,9 @@
|
||||
],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {},
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
},
|
||||
"strict": false,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
|
||||
+6
-3
@@ -25,6 +25,9 @@ export default defineConfig({
|
||||
// Pin shared deps to pretix's node_modules to prevent duplicate instances
|
||||
// across plugins whose node_modules live in sibling directories
|
||||
dedupe: [...SHARED_DEPS, '@vue/runtime-core', '@vue/reactivity', '@vue/shared'],
|
||||
alias: {
|
||||
'@': path.resolve(import.meta.dirname, 'src'),
|
||||
}
|
||||
},
|
||||
server: {
|
||||
fs: {
|
||||
@@ -37,12 +40,12 @@ export default defineConfig({
|
||||
},
|
||||
build: {
|
||||
manifest: true,
|
||||
outDir: path.resolve(__dirname, 'src/pretix/static.dist/vite/control'),
|
||||
outDir: path.resolve(import.meta.dirname, 'src/pretix/static.dist/vite/control'),
|
||||
rollupOptions: {
|
||||
preserveEntrySignatures: 'exports-only',
|
||||
input: {
|
||||
'webcheckin/main': path.resolve(__dirname, 'src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.ts'),
|
||||
'checkinrules/main': path.resolve(__dirname, 'src/pretix/static/pretixcontrol/js/ui/checkinrules/index.ts'),
|
||||
'webcheckin/main': path.resolve(import.meta.dirname, 'src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.ts'),
|
||||
'checkinrules/main': path.resolve(import.meta.dirname, 'src/pretix/static/pretixcontrol/js/ui/checkinrules/index.ts'),
|
||||
...Object.fromEntries(SHARED_DEPS.map(dep => [`_vendor/${dep}`, `virtual:vendor/${dep}`])),
|
||||
...pretixPluginEntries,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user