J3.x

Desarrollo de un Componente MVC/Agregar gestión de idioma

From Joomla! Documentation

< J3.x:Developing an MVC Component
Revision as of 16:20, 25 August 2015 by Abulafia (talk | contribs) (Created page with "y/o (en la versión 1.5):")
Other languages:
English • ‎Nederlands • ‎español • ‎français • ‎العربية • ‎中文(台灣)‎
Copyedit.png
This Page Needs Your Help

This page is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.


Joomla! 
3.x
Tutorial
Desarrollo de un Componente MVC

Agregar una variable de petición en el tipo de menú

Utilizando la base de datos

Lado servidor básico

Agregar gestión de idioma

Agregar acciones del lado servidor

Agregar decoraciones del lado servidor

Agregar verificaciones

Agregar categorías

Agregar configuración

  1. Agregar ACL

Agregar un archivo de secuencia de comandos instalar-desinstalar-actualizar

Agregar un formulario del lado cliente

  1. Agregar una imagen
  2. Agregar un mapa
  3. Agregar AJAX
  4. Agregar un alias

Usar la facilidad filtro de idioma

  1. Agregar una Modal
  2. Agregar Asociaciones
  3. Agregar Comprobación
  4. Agregar Ordenamiento
  5. Agregar Niveles
  6. Agregar Control de Versiones
  7. Agregar Etiquetas
  8. Agregar Accesos
  9. Agregar procesos por lote
  10. Agregar Caché
  11. Agregar un Canal de Noticias

Agregar un servidor de actualización

  1. Agregar campos personalizados
  2. Upgrading to Joomla4



Esta es una serie multi-artículos de tutoriales sobre cómo desarrollar un Componente Modelo-Vista-Controlador para Joomla! VersiónJoomla 3.x.

Comenzar con la Introducción, y navegar por los artículos de esta serie usando el botón de navegación en la parte inferior o en el cuadro de la derecha (los "Artículos de esta serie").



Introducción

Este artículo es parte del tutorial Desarrollo de un Componente MVC para Joomla! 3.2. Te invitamos a leer las partes anteriores del tutorial antes de leer esto. Joomla! 3.2 gestiona idiomas para los componentes en cuatro situaciones diferentes:

  • la visualización de un componente en el sitio público
  • la gestión de un componente en el servidor
  • la gestión de menús en el lado servidor
  • la instalación de un componente

Joomla! 3.2 utiliza dos ubicaciones diferentes para las capetas de idiomas:

  • una en administrator/language o language
  • una en la carpeta del componente (administrator/components/*component*/language o components/*component*/language)

Depende de cómo se instala el componente.

Agregar traducción del idioma en el sitio público

Con tus administrador y editor de archivos favoritos, pon un archivo site/language/en-GB/en-GB.com_helloworld.ini. Este archivo contiene la traducción de la parte pública. Por el momento, este archivo está vacío.

site/language/en-GB/en-GB.com_helloworld.ini

Por el momento, no hay traducciones de cadenas en este archivo.

Agregar traducción de idioma en la gestión del componente

Con tus administrador y editor de archivos favoritos, pon un archivo admin/language/en-GB/en-GB.com_helloworld.ini. Este archivo contiene la traducción para la parte del servidor.

admin/language/en-GB/en-GB.com_helloworld.ini

; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

COM_HELLOWORLD_NUM="#"
COM_HELLOWORLD_PUBLISHED="Published"
COM_HELLOWORLD_HELLOWORLDS_NAME="Name"
COM_HELLOWORLD_ID="Id"

COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_DESC="This message will be displayed"
COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_LABEL="Message"
COM_HELLOWORLD_HELLOWORLD_HEADING_GREETING="Greeting"
COM_HELLOWORLD_HELLOWORLD_HEADING_ID="Id"

Adding language translation when managing the menus in the backend

Con tus administrador y editor de archivos favoritos, pon un archivo admin/language/en-GB/en-GB.com_helloworld.sys.ini. Este archivo contiene la traducción para el lado servidor.

admin/language/en-GB/en-GB.com_helloworld.sys.ini

; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

COM_HELLOWORLD="Hello World!"
COM_HELLOWORLD_DESCRIPTION="This is the Hello World description"
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE="Hello World"
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC="This view displays a selected message"
COM_HELLOWORLD_MENU="Hello World!"

Archivo de Idioma Opciones de Ubicación

A partir de la versión 1.7 hay 2 formas de instalar los archivos de idioma para una extensión. Se puede usar uno, el otro o una combinación de ambos.

En la versión 1.5, los archivos se instalan en la carpeta de idiomas del NÚCLEO (ROOT/administrator/language/ y ROOT/language/). Desde la versión 1.6, los archivos se instalan en una carpeta "idioma" en la raíz de la extensión.

Por lo tanto, una extensión puede incluir una carpeta de idioma con un .sys.ini diferente del que se ha instalado en las carpetas de idioma del núcleo de Joomla. (Este último no está incluido en la carpeta de ese lenguaje, pero en la raíz o en cualquier otra carpeta no instalada).

Esto nos permite mostrar 2 descripciones diferentes: una desde el sys.ini en la carpeta "idioma" se utiliza como un mensaje que se muestra cuando termine la instalación, el otro (desde .ini) se utiliza para el funcionamiento "normal", es decir, cuando la extensión es editada en el lado servidor. Esto puede ser muy útil cuando la instalación también utiliza algunas secuencias de comandos y requiere un valor diferente de la descripción.

Debes Tener en Cuenta!

El archivo sys.ini también se utiliza para traducir el nombre de las extensiones en algunos Gestores del lados servidor back-end y a proporciona al menú la traducción a los componentes.

Por lo tanto, el xml incluiría desde la versión 1.6:

<files>
<[...]
<folder>language</folder>  // This folder HAS to include the right subfolders, i.e. language/en-GB/ ... language/fr-FR/
<filename>whatever</filename>
[...]
</files>

<administration>
    <files folder="admin">
        <[...]
        <folder>language</folder>
        <filename>whatever</filename>
        <[...]
    </files>
</administration>

y/o (en la versión 1.5):

<languages folder="joomlacorelanguagefolders"> // If using another language folder for cleanliness. (Any folder name will fit.)
<language tag="en-GB">en-GB/en-GB.whatever.ini</language> // or
<language tag="en-GB">en-GB.whatever.ini</language> if no tagged subfolder
<language tag="en-GB">en-GB/en-GB.whatever.sys.ini</language> // or
<language tag="en-GB">en-GB.whatever.sys.ini</language> if no tagged subfolder
</languages>

o simplemente en la RAÍZ:

<languages>
<language tag="en-GB">en-GB.whatever.ini</language>
<language tag="en-GB">en-GB.whatever.sys.ini</language>
</languages>

Language file used by the installation script during the installation of a component(the first install, not an upgrade) obeys specific rules described in the article, Specification of language files. During the first installation, only the language file included in the component folder (/administrator/components/com_helloworld/language) is used when present. If this file is only provided in the CORE language folder (/administrator/language), no translation occurs. This also applies to KEYs used in the manifest file.

When upgrading or uninstalling the extension (not installing), it is the sys.ini file present in the extension root language folder which will display the result of the installation from the description key/value. Thereafter, if present, the sys.ini as well as the .ini installed in the CORE language folder will have priority over the files present in the root language folder of the extension.

Advantages of Extension "Language" Folder

One advantage of installing the files in the extension "language" folder is that these are not touched when updating a language pack.

The other advantage is that this folder can include multiple languages (en-GB always, fr-FR, it-IT, etc.) not requiring the user to install the corresponding language pack. This is handy as they are available if, later on, a user installs the corresponding pack.

Packaging the component

Content of your code directory

Create a compressed file of this directory or directly download the archive and install it using the extension manager of Joomla. You can add a menu item of this component using the menu manager in the backend.

helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2.0" method="upgrade">

	<name>COM_HELLOWORLD</name>
	<!-- The following elements are optional and free of formatting constraints -->
	<creationDate>January 2014</creationDate>
	<author>John Doe</author>
	<authorEmail>john.doe@example.org</authorEmail>
	<authorUrl>http://www.example.org</authorUrl>
	<copyright>Copyright Info</copyright>
	<license>License Info</license>
	<!--  The version string is recorded in the components table -->
	<version>0.0.8</version>
	<!-- The description is optional and defaults to the name -->
	<description>COM_HELLOWORLD_DESCRIPTION</description>

	<install> <!-- Runs on install -->
		<sql>
			<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
		</sql>
	</install>
	<uninstall> <!-- Runs on uninstall -->
		<sql>
			<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
		</sql>
	</uninstall>
	<update> <!-- Runs on update; New since J2.5 -->
		<schemas>
			<schemapath type="mysql">sql/updates/mysql</schemapath>
		</schemas>
	</update>

	<!-- Site Main File Copy Section -->
	<!-- Note the folder attribute: This attribute describes the folder
		to copy FROM in the package to install therefore files copied
		in this section are copied from /site/ in the package -->
	<files folder="site">
		<filename>index.html</filename>
		<filename>helloworld.php</filename>
		<filename>controller.php</filename>
		<folder>views</folder>
		<folder>models</folder>
	</files>

        <languages folder="site/language">
		<language tag="en-GB">en-GB/en-GB.com_helloworld.ini</language>
        </languages>

	<administration>
		<!-- Administration Menu Section -->
		<menu link='index.php?option=com_helloworld'>COM_HELLOWORLD_MENU</menu>
		<!-- Administration Main File Copy Section -->
		<!-- Note the folder attribute: This attribute describes the folder
			to copy FROM in the package to install therefore files copied
			in this section are copied from /admin/ in the package -->
		<files folder="admin">
			<!-- Admin Main File Copy Section -->
			<filename>index.html</filename>
			<filename>helloworld.php</filename>
			<filename>controller.php</filename>
			<!-- SQL files section -->
			<folder>sql</folder>
			<!-- tables files section -->
			<folder>tables</folder>
			<!-- models files section -->
			<folder>models</folder>
			<!-- views files section -->
			<folder>views</folder>
		</files>
		<languages folder="admin/language">
        		<language tag="en-GB">en-GB/en-GB.com_helloworld.ini</language>
                        <language tag="en-GB">en-GB/en-GB.com_helloworld.sys.ini</language>
		</languages>
	</administration>

</extension>

In this helloworld.xml file, languages are installed in:

  • administrator/language for the admin part (look at the xml languages tag).
  • components/com_helloworld/language for the site part (there are no xml languages tag in the site part of the xml description file, but the language folder is included).
Info non-talk.png
General Information

Please create a pull request or issue at https://github.com/joomla/Joomla-3.2-Hello-World-Component for any code descprepancies or if editing any of the source code on this page.

Contributors