IO-2687 Delay template load to wait for translations.
This commit is contained in:
@@ -34,19 +34,20 @@ export function PartDispatchTableComponent({
|
|||||||
// const selectedBill = search.billid;
|
// const selectedBill = search.billid;
|
||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
const Templates = TemplateList("job_special");
|
const Templates = TemplateList("job_special", job);
|
||||||
|
|
||||||
const {refetch} = billsQuery;
|
const {refetch} = billsQuery;
|
||||||
|
|
||||||
const recordActions = (record) => (
|
const recordActions = (record) => (
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<PrintWrapperComponent
|
<PrintWrapperComponent
|
||||||
templateObject={{
|
templateObject={{
|
||||||
name: Templates.parts_dispatch.key,
|
name: Templates.parts_dispatch.key,
|
||||||
variables: {id: record.id},
|
variables: { id: record.id },
|
||||||
}}
|
}}
|
||||||
/>
|
messageObject={{ subject: Templates.parts_dispatch.subject }}
|
||||||
</Space>
|
/>
|
||||||
|
</Space>
|
||||||
);
|
);
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { initReactI18next } from 'react-i18next';
|
|||||||
import en_Translation from './en_us/common.json';
|
import en_Translation from './en_us/common.json';
|
||||||
import es_Translation from './es/common.json';
|
import es_Translation from './es/common.json';
|
||||||
import fr_Translation from './fr/common.json';
|
import fr_Translation from './fr/common.json';
|
||||||
|
import { GenerateTemplates } from '../utils/RenderTemplate';
|
||||||
|
|
||||||
// the translations
|
// the translations
|
||||||
// (tip move them in a JSON file and import them)
|
// (tip move them in a JSON file and import them)
|
||||||
@@ -13,19 +14,27 @@ const resources = {
|
|||||||
'es-MX': es_Translation,
|
'es-MX': es_Translation,
|
||||||
};
|
};
|
||||||
i18n
|
i18n
|
||||||
.use(initReactI18next)
|
|
||||||
.use(LanguageDetector) // passes i18n down to react-i18next
|
.use(LanguageDetector) // passes i18n down to react-i18next
|
||||||
.init({
|
.use(initReactI18next)
|
||||||
resources,
|
.init(
|
||||||
//lng: "en",
|
{
|
||||||
detection: {},
|
resources,
|
||||||
fallbackLng: 'en-US',
|
//lng: "en",
|
||||||
debug: import.meta.env.DEV,
|
detection: {},
|
||||||
//keySeparator: false, // we do not use keys in form messages.welcome
|
fallbackLng: 'en-US',
|
||||||
interpolation: {
|
debug: import.meta.env.DEV,
|
||||||
escapeValue: false, // react already safes from xss
|
react: {
|
||||||
skipOnVariables: false,
|
useSuspense: true,
|
||||||
|
},
|
||||||
|
//keySeparator: false, // we do not use keys in form messages.welcome
|
||||||
|
interpolation: {
|
||||||
|
escapeValue: false, // react already safes from xss
|
||||||
|
skipOnVariables: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
(error) => {
|
||||||
|
GenerateTemplates();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|||||||
@@ -14,7 +14,12 @@ const server = import.meta.env.VITE_APP_REPORTS_SERVER_URL;
|
|||||||
|
|
||||||
jsreport.serverUrl = server;
|
jsreport.serverUrl = server;
|
||||||
|
|
||||||
const Templates = TemplateList();
|
let Templates;
|
||||||
|
export function GenerateTemplates(){
|
||||||
|
//Required as a part of the transition to Vite.
|
||||||
|
//Previous method had the template hash generating before translations loaded, resulting in empty files.
|
||||||
|
Templates = TemplateList()
|
||||||
|
}
|
||||||
|
|
||||||
export default async function RenderTemplate(
|
export default async function RenderTemplate(
|
||||||
templateObject,
|
templateObject,
|
||||||
|
|||||||
Reference in New Issue
Block a user