Created
February 27, 2013 08:13
-
-
Save mpampols/5046162 to your computer and use it in GitHub Desktop.
Copy the two files inside /custom folder of your Plone instance and run "/duplicarCarpeta" inside the context of the folder you want to translate. The second script will run and copy all the original contents to the linked translated folders and will set the setLanguage to the destination language.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request = container.REQUEST | |
idiomactual = context.REQUEST.other['LANGUAGE'] | |
from Products.CMFCore.utils import getToolByName | |
urltool = getToolByName(context, 'portal_url') | |
if context.restrictedTraverse('@@plone').isStructuralFolder(): | |
path_to_translate = '/'.join(context.getPhysicalPath()) | |
else: | |
path_to_translate = '/'.join(context.aq_inner.aq_parent.getPhysicalPath()) | |
print "Estás apunto de copiar la carpeta y sus contenidos: " | |
print "<br/>(" + str(context.getLanguage()) + ") -- " + str(context.absolute_url()) | |
original_language = str(context.getLanguage()) | |
translations = context.aq_parent.getTranslations() | |
print "<br/><br/>A la(s) carpeta(s):" | |
for translation in translations: | |
if (translation != original_language): | |
print "<br/>(" + str(translation) + ") -- " + str(translations[translation][0].absolute_url()) | |
print "<br/><br/>Nota: Los elementos pasarán a tener configurado el nuevo idioma" | |
print "<br/><a href='duplicarCarpetaAhora'>Copiar ahora</a>" | |
return printed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request = container.REQUEST | |
idiomactual = context.REQUEST.other['LANGUAGE'] | |
from Products.CMFCore.utils import getToolByName | |
urltool = getToolByName(context, 'portal_url') | |
# Copy folder | |
object_to_copy = context.aq_parent.manage_copyObjects([context.id]) | |
print "Copiant contingut de: ", str(context.absolute_url()) | |
# Destination path | |
translations = context.aq_parent.getTranslations() | |
original_language = str(context.getLanguage()) | |
for translation in translations: | |
if (translation != original_language): | |
translations[translation][0].manage_pasteObjects(object_to_copy) | |
print "Contingut copiat a: ", str(translations[translation][0].aq_parent.absolute_url()), "... OK" | |
# Change language | |
for translation in translations: | |
if (translation != original_language): | |
path_to_translate = '/'.join(translations[translation][0].getPhysicalPath()) | |
results = context.portal_catalog({'path':{'query':path_to_translate,'level':0,'depth':99}}) | |
for result in results: | |
result.getObject().setLanguage(str(translation)) | |
print "Idioma modificat al objecte: ", str(result.getObject().absolute_url()) | |
return printed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment