Project

General

Profile

CdmDataportalDev » History » Version 4

Niels Hoffmann, 11/15/2010 03:03 PM

1 1 Niels Hoffmann
2 1 Niels Hoffmann
3 1 Niels Hoffmann
4 1 Niels Hoffmann
5 1 Niels Hoffmann
# Dataportal Development Resources
6 1 Niels Hoffmann
7 1 Niels Hoffmann
8 1 Niels Hoffmann
This page holds information on developing the CDM Dataportal. The product page of the CDM Dataportal may be found here: http://wp5.e-taxonomy.eu/portal
9 1 Niels Hoffmann
10 1 Niels Hoffmann
11 1 Niels Hoffmann
{{>toc}}
12 1 Niels Hoffmann
13 1 Niels Hoffmann
14 1 Niels Hoffmann
15 1 Niels Hoffmann
16 1 Niels Hoffmann
----
17 1 Niels Hoffmann
18 1 Niels Hoffmann
19 1 Niels Hoffmann
20 1 Niels Hoffmann
21 2 Niels Hoffmann
## Environment Setup
22 1 Niels Hoffmann
23 1 Niels Hoffmann
24 2 Niels Hoffmann
(Drupal + Apache + Php + [[MySQL]] + Eclipse)
25 1 Niels Hoffmann
26 2 Niels Hoffmann
* [[DeveloperEnvironmentSetup|DeveloperEnvironmentSetup Windows 1]] and [[InstallingDrupal|DeveloperEnvironmentSetup Windows 2]]
27 1 Niels Hoffmann
28 2 Niels Hoffmann
* [[DeveloperEnvironmentSetupOsX|Os X]]
29 2 Niels Hoffmann
30 2 Niels Hoffmann
31 1 Niels Hoffmann
32 4 Niels Hoffmann
## Translations & Localization
33 4 Niels Hoffmann
34 4 Niels Hoffmann
35 4 Niels Hoffmann
 **Links** 
36 4 Niels Hoffmann
37 4 Niels Hoffmann
38 4 Niels Hoffmann
39 4 Niels Hoffmann
* http://drupal.org/translators 
40 4 Niels Hoffmann
41 4 Niels Hoffmann
42 4 Niels Hoffmann
 **Drupal translations can be provided for individual modules and themes:** 
43 4 Niels Hoffmann
44 4 Niels Hoffmann
45 4 Niels Hoffmann
Contributed module/theme (called module from now on) interface translations are a bit more complex than core Drupal translations, because the translation template (POT) files are not generated automatically for you. Some developers generate translation templates for their modules, and put them into their module's translations directory. This is a nice gesture, but unfortunately these templates get outdated quickly. So it is advised that you generate fresh templates with the translation template extractor when you start translating. Translations of modules should be placed, along with the POT file, in the 'translations' subdirectory of the module. If you are not the module maintainer and you have created a translation, submit an issue against that module and attach your module files so the maintainer can add them to the project. (from http://drupal.org/translators)
46 4 Niels Hoffmann
47 4 Niels Hoffmann
48 4 Niels Hoffmann
 **Create POT files using the [Translation template extractor](http://drupal.org/project/potx**) 
49 4 Niels Hoffmann
50 4 Niels Hoffmann
51 4 Niels Hoffmann
52 4 Niels Hoffmann
### Using the locale module to replace terms
53 4 Niels Hoffmann
54 4 Niels Hoffmann
55 4 Niels Hoffmann
In the following a method to transform hard coded English (= default) terms into other English terms is described, this technique has been used to solve #1325:
56 4 Niels Hoffmann
57 4 Niels Hoffmann
58 4 Niels Hoffmann
1. activate the locale module 
59 4 Niels Hoffmann
60 4 Niels Hoffmann
1. go to `admin/settings/locale/language/add` and add a "Custom Language" e.g.: **Language code: en-trans** , **Language name in English: english with replacements** 
61 4 Niels Hoffmann
62 4 Niels Hoffmann
1. **enable** en-trans and set it as **default** 
63 4 Niels Hoffmann
64 4 Niels Hoffmann
65 4 Niels Hoffmann
Setup the translations - two alternatives
66 4 Niels Hoffmann
67 4 Niels Hoffmann
68 4 Niels Hoffmann
* Go to "Manage Strings" `admin/settings/locale/string/search` and search the string to be replaced, and translate it.
69 4 Niels Hoffmann
70 4 Niels Hoffmann
* import at `admin/settings/locale/language/import` a **.po for the *Language code: en-trans** which might have been disseminated with the theme in the subfolder `translations/en-trans/*.po` 
71 4 Niels Hoffmann
72 4 Niels Hoffmann
This rather simple approach might lead to conflicts if the same string is used in differen places but with diffrent meaning. So it is nessecary to make strings in particualr terms uniquely identifieable. This becomes possible using the second parameter of the `t()` function in Drupal. If '%' is used as second parameter the string will be passed to the `theme_placeholder()` function which can be implemented by the cdmdataportal module in order to strip of a idendifier prefix from the string. This prefix should either contain information on the type of the string (whether it is a term from cdm, a field name from a metata object, etc) or on the position in the data portal (page path; x-path of the html element; css class like attribute? renderpath ?) or both. -> *'TO BE DISCUSSED*. If there is a translation for the string with prefix whole string would be replaced by the translation process. If there is not translation the prefix will be stripped of by the placeholder function.
73 4 Niels Hoffmann
74 4 Niels Hoffmann
 
75 4 Niels Hoffmann
76 4 Niels Hoffmann
here is an example in code snippets
77 4 Niels Hoffmann
78 4 Niels Hoffmann
~~~
79 4 Niels Hoffmann
80 4 Niels Hoffmann
$out = t('{term}Author', '%'); 
81 4 Niels Hoffmann
82 4 Niels Hoffmann
// the prefix "{term}" will be stripped of in cdm_dataportal_placeholder()
83 4 Niels Hoffmann
// if the whole string has not been replace by the translation applied 
84 4 Niels Hoffmann
// by the localization module
85 4 Niels Hoffmann
86 4 Niels Hoffmann
function cdm_dataportal_placeholder($text) {
87 4 Niels Hoffmann
	$pos1 = strpos($text, '{');
88 4 Niels Hoffmann
	$pos2 = strpos($text, '}', $pos1 + 1);
89 4 Niels Hoffmann
	if($pos1 == 0 && $pos2 > $pos1 + 1 ){
90 4 Niels Hoffmann
		$text = substr($text, $pos2);
91 4 Niels Hoffmann
	}
92 4 Niels Hoffmann
  return '<em>'. check_plain($text) .'</em>';
93 4 Niels Hoffmann
}
94 4 Niels Hoffmann
95 4 Niels Hoffmann
~~~
96 2 Niels Hoffmann
97 3 Niels Hoffmann
98 3 Niels Hoffmann
## External Resources / Links
Add picture from clipboard (Maximum size: 40 MB)