| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   <BaseDialog | 
					
						
							|  |  |  |     v-model="dialog" | 
					
						
							|  |  |  |     :icon="$globals.icons.translate" | 
					
						
							|  |  |  |     :title="$t('language-dialog.choose-language')" | 
					
						
							|  |  |  |   > | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |     <v-card-text> | 
					
						
							|  |  |  |       {{ $t("language-dialog.select-description") }} | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       <v-autocomplete | 
					
						
							| 
									
										
										
										
											2025-07-21 02:51:28 -05:00
										 |  |  |         v-model="selectedLocale" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         :items="locales" | 
					
						
							|  |  |  |         item-title="name" | 
					
						
							| 
									
										
										
										
											2025-07-21 02:51:28 -05:00
										 |  |  |         item-value="value" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         class="my-3" | 
					
						
							|  |  |  |         hide-details | 
					
						
							|  |  |  |         variant="outlined" | 
					
						
							| 
									
										
										
										
											2025-07-21 02:51:28 -05:00
										 |  |  |         @update:model-value="onLocaleSelect" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       > | 
					
						
							|  |  |  |         <template #item="{ item, props }"> | 
					
						
							|  |  |  |           <div | 
					
						
							|  |  |  |             v-bind="props" | 
					
						
							|  |  |  |             class="px-2 py-2" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <v-list-item-title> {{ item.raw.name }} </v-list-item-title> | 
					
						
							|  |  |  |             <v-list-item-subtitle> | 
					
						
							|  |  |  |               {{ item.raw.progress }}% {{ $t("language-dialog.translated") }} | 
					
						
							|  |  |  |             </v-list-item-subtitle> | 
					
						
							|  |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |         </template> | 
					
						
							|  |  |  |       </v-autocomplete> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       <i18n-t keypath="language-dialog.how-to-contribute-description"> | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |         <template #read-the-docs-link> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <a | 
					
						
							|  |  |  |             href="https://docs.mealie.io/contributors/translating/" | 
					
						
							|  |  |  |             target="_blank" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             {{ $t("language-dialog.read-the-docs") }} | 
					
						
							|  |  |  |           </a> | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |         </template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       </i18n-t> | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |     </v-card-text> | 
					
						
							|  |  |  |   </BaseDialog> | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  | import { useLocales } from "~/composables/use-locales"; | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  |   props: { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     modelValue: { | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  |       type: Boolean, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       required: true, | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   emits: ["update:modelValue"], | 
					
						
							|  |  |  |   setup(props, { emit }) { | 
					
						
							|  |  |  |     const dialog = computed({ | 
					
						
							|  |  |  |       get: () => props.modelValue, | 
					
						
							|  |  |  |       set: value => emit("update:modelValue", value), | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |     const { locales: LOCALES, locale, i18n } = useLocales(); | 
					
						
							| 
									
										
										
										
											2025-07-21 02:51:28 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const selectedLocale = ref(locale.value); | 
					
						
							|  |  |  |     const onLocaleSelect = (value: string) => { | 
					
						
							|  |  |  |       if (value && locales.some(l => l.value === value)) { | 
					
						
							|  |  |  |         locale.value = value as any; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     watch(locale, () => { | 
					
						
							|  |  |  |       dialog.value = false; // Close dialog when locale changes
 | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const locales = LOCALES.filter(lc => | 
					
						
							|  |  |  |       i18n.locales.value.map(i18nLocale => i18nLocale.code).includes(lc.value as any), | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       dialog, | 
					
						
							|  |  |  |       i18n, | 
					
						
							|  |  |  |       locales, | 
					
						
							|  |  |  |       locale, | 
					
						
							| 
									
										
										
										
											2025-07-21 02:51:28 -05:00
										 |  |  |       selectedLocale, | 
					
						
							|  |  |  |       onLocaleSelect, | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2022-03-19 16:33:55 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-03-19 22:27:40 +01:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> |