Home › Forum › Problemi Vari con WP › file po nel tema child
-
AutorePost
-
-
23 Dicembre 2015 alle 15:59 #30435apache72Partecipante
buonasera, ho letto il wiki sui tema child, però ho una curiosità sui file .po Vorrei sapere se la procedura per inserirli nel tema child è la stessa che per gli altri file, perchè a ma non funzionano. In pratica nel tema padre ho una cartella Languages in cui ci sono ad es. default.po e default.mo Ora io vado a modificare con poedit però non voglio nuovamente reinserirli al prossimo aggiornamento del tema quindi vorrei metterli nel tema child. Ho creato quindi una cartella languages anche nel tema child e messo i files .po e .mo modificati ma non funzionano. Quindi ho eliminato la cartella languages e inserito direttamente i 2 files nellla cartella child ma neanche cosଠfunzionano, mentre se lascio le modifiche nel tema padre è tutto ok. Vorrei conoscere qual è la procedura corretta per inserirli nel child vi ringrazio e vi auguro buone feste!
-
23 Dicembre 2015 alle 17:20 #119469TittiModeratore
https://codex.wordpress.org/Function_Reference/load_child_theme_textdomain
All’inizio del functions.php del child.
-
26 Dicembre 2015 alle 14:16 #119475apache72Partecipante
grazie Titti…scusami ma ho riletto diverse volte l’articolo, ma non so dvoe sbaglio perchè non mi funziona. Ho creato un file functions.php nella cartella del tema child e al suo interno ho inserito la stringa dell’articolo
<?php load_child_theme_textdomain( $domain, $path ) ?>
e nella stessa cartella child ho inserito i 2 file it_IT.mo e it_IT.po tradotti ma non mi funziona. Aloora ho provato a copiare l’intero file functions.php del padre e inserendo la stringa di sopra all’inizio in modo da avere
<?php load_child_theme_textdomain( $domain, $path ) ?>
<?php
/**
* This file represents an example of the code that themes would use -.....non so dove sbaglio probabilmente va inserito anche questo da qualche parte?
add_action( 'after_setup_theme', 'my_child_theme_setup' );
function my_child_theme_setup() {
load_child_theme_textdomain( 'my_child_theme', get_stylesheet_directory() . '/languages' );
} -
26 Dicembre 2015 alle 19:29 #119476TittiModeratore
non so dove sbaglio
Ovunque. Innanzitutto dici di aver creato un functions.php nella cartella del tema child – perché, non l’avevi già ? Come carichi il foglio stile del child?
Partiamo da qua anche se non c’entra con i file di traduzione, però mi sa che bisogna andare più a monte.
Per le traduzioni non va bene niente di quello che hai fatto: tu hai solo copiato alla lettera ciò che hai visto scritto in quella pagina, “usage” ed “esempio”.
Dal tema figlio scarica il foglio stile e il functions, incollali ognuno su pastebin e pubblica qui i due link.
(Del foglio stile non m’interessa tutto, solo l’intestazione e le prime righe dello stile).
-
28 Dicembre 2015 alle 19:42 #119486apache72Partecipante
no, non avevo un functions.php, l’ho creato per evitare d’imprtare l’url @ usando la stringa che ccpnsiglia nel wiki
<?php
add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_theme_style’ );
function enqueue_parent_theme_style() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ );
}
quindi nel functions ho solo questo e ti garantisco che non c’è il file ho riscarticato il child e non c’è.
Per lo style.css si tratta di un tema che sto ancora sperimentando ed è un tema premium, quindi non so se ti serve conoscere il link al tema , che per motivi miei, non vorrei pubblicare o se ti serve qualche altra info ma non c’è quasi niente se non appunto l’autore e il nome del tema con il link, scusami però dimmi tu….
e poi c’è un style.less in cui c’è l’intestazione come nello style.css e poi : CONTENT:
color variables
variables
html5 and responsive content
reset
wordpress core…..ecc….
quindi se puoi dirmi cosa serve di preciso ti ringrazio
se hgo sbagliato qualcosa scusami, ovviamente so che i temi premium non sono supportati qui, ma la mia domanda ovviamente rigyuarda altro…
-
29 Dicembre 2015 alle 10:01 #119487TittiModeratore
quindi nel functions ho solo questo e ti garantisco che non c’è il file ho riscarticato il child e non c’è.
Non so di cosa parli, ma lasciamo perdere perché quello che dici è davvero poco utile e in qualche caso nemmeno vero.
Non so neppure cosa speravi d’ottenere non dicendo tutta la verità subito.
Ti ho chiesto l’inizio del foglio stile per vedere se avevi usato l’import, dato che hai fatto capire TU STESSO che ancora non avevi functions.php e di averlo creato solo dopo la mia risposta.
Per quanto riguarda il functions, ti avevo detto di metterlo cosଠcome hai descritto che era su pastebin per fare un piacere a te – non a me – correggendolo io direttamente là di modo che poi tu dovessi solo caricarlo, questo pensando che si trattasse del tuo solito tema dato che hai omesso informazioni importanti, tema che potevo anche scaricare per cercare il text_domain nel caso non fosse il nome del tema stesso. Bene, non farlo ora perché non ha più senso.
Poi dici che la tua domanda riguarda “altro”, e invece no la tua domanda riguarda il tema com’è evidente, e il fatto che sia premium conta eccome.
Vuoi sapere la prassi, e la prassi comune è questa – se leggi attentamente (cosa che non fa mai nessuno compreso te) capisci.
Metti nel file functions.php:
// Carica i file tradotti del tema child
load_child_theme_textdomain( 'text_domain', get_stylesheet_directory() . '/languages' );Significa che devi cercare il nome del textdomain e inserirlo al suo posto tra le virgolette. Di solito è il nome del tema, ma se non è cosଠdevi cercarlo tra i file del tema padre, in occasione di chiamate come _e() o anche solo __(), in cui il secondo parametro è il text domain, es.: __( ‘stringa traducibile’, ‘text_domain’ ).
Significa anche che devi mettere i file di traduzione in una cartella “languages” nella stessa directory del foglio stile.
Infine, i file di traduzione in quella cartella devono essere chiamati it_IT.po e it_IT.mo, non “default” o qualcos’altro.
Se tutto ciò non funziona, devi chiedere all’autore del tema premium perché vuol dire che qualcosa è stato fatto diversamente.
-
30 Dicembre 2015 alle 23:55 #119493apache72Partecipante
mi spiace del malinteso, mea culpa aver tralasciato di dire che stavo lavorando ad un nuovo tema..sorry, credevo che la risposta fosse univoca indipendentemente dal tema
Comunque ho risolto grazie Titti alla tua risposta. grazie di nuovo
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.