Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/mrgnw/ananas. learn multiple languages at once ananas.xcc.es
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839import { writable } from 'svelte/store';import { browser } from '$app/environment';
// Create a writable store with an initial empty stateexport const translationInput = writable('');
// Initialize store from localStorage if we're in the browserif (browser) { const savedTranslation = localStorage.getItem('translation-input'); if (savedTranslation) { translationInput.set(savedTranslation); } // Set up subscription to save to localStorage when value changes translationInput.subscribe(value => { localStorage.setItem('translation-input', value); });}
// Helper functions for common operationsexport function updateTranslationInput(text) { translationInput.set(text);}
export function clearTranslationInput() { translationInput.set('');}
// This function can be called to manually initialize from storage// (useful if you need to force a refresh from localStorage)export function initializeFromStorage() { if (browser) { const saved = localStorage.getItem('translation-input'); if (saved) { translationInput.set(saved); } }}