summaryrefslogtreecommitdiff
path: root/includes/extras/functions.tr.php
blob: f3f31e51ec49a7a73e2fb0ff30e51ec2fe501db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
 * Turkish Date Functions that can be used by any page in webtrees
 * Other functions that are specific to Turkish can be added here too
 *
 * The functions in this file are common to all webtrees pages and include date conversion
 * routines and sorting functions.
 *
 * webtrees: Web based Family History software
 * Copyright (C) 2010 webtrees development team.
 *
 * Derived from PhpGedView
 * Copyright (C) 2002 to 2003  John Finlay and Others
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package webtrees
 * @version $Id$
 */

if (!defined('WT_WEBTREES')) {
	header('HTTP/1.0 403 Forbidden');
	exit;
}

define('WT_FUNCTIONS_TR_PHP', '');

////////////////////////////////////////////////////////////////////////////////
// Localise a date. "[qualifier] date [qualifier date] [qualifier]"
////////////////////////////////////////////////////////////////////////////////
function date_localisation_tr(&$q1, &$d1, &$q2, &$d2, &$q3) {
	global $pgv_lang;

	switch ($q1) {
	case 'from':
	case 'bef':
	case 'aft':
		if (preg_match('/(\d{3,4})/', $d1, $match)) { // Extract year
			switch ($match[1] % 10) {
			case 0:
				switch ($match[1] % 100) {
				case 0:
				case 20:
				case 50:
				case 70:
				case 80: $q1=str_replace('#EXT#', 'den', $pgv_lang[$q1]); break;
				default: $q1=str_replace('#EXT#', 'dan', $pgv_lang[$q1]); break;
				}
				break;
			case 6:
			case 9: $q1=str_replace('#EXT#', 'dan', $pgv_lang[$q1]); break;
			default: $q1=str_replace('#EXT#', 'den', $pgv_lang[$q1]); break;
			}
		} else {
			$q1=str_replace('#EXT#', 'den', $pgv_lang[$q1]);
		}
		break;
	case 'to':
		if (preg_match('/(\d{3,4})/', $d1, $match)) { // Extract year
			switch ($match[1]) {
			case '0':
			case '9': $q1=str_replace('#EXT#', 'a', $pgv_lang[$q1]); break;
			case '2':
			case '7': $q1=str_replace('#EXT#', 'ye', $pgv_lang[$q1]); break;
			case '6': $q1=str_replace('#EXT#', 'ya', $pgv_lang[$q1]); break;
			default: $q1=str_replace('#EXT#', 'e', $pgv_lang[$q1]); break;
			}
		} else {
			$q1=str_replace('#EXT#', 'e', $pgv_lang[$q1]);
		}
		break;
	default:
		if (isset($pgv_lang[$q1]))
			$q1=$pgv_lang[$q1];
		break;
	}

	switch ($q2) {
	case 'to':
		if (preg_match('/(\d{3,4})/', $d2, $match)) { // Extract year
			switch ($match[1] % 10) {
			case 0:
			case 9: $q2=str_replace('#EXT#', 'a', $pgv_lang[$q2]); break;
			case 2:
			case 7: $q2=str_replace('#EXT#', 'ye', $pgv_lang[$q2]); break;
			case 6: $q2=str_replace('#EXT#', 'ya', $pgv_lang[$q2]); break;
			default: $q2=str_replace('#EXT#', 'e', $pgv_lang[$q2]); break;
			}
		} else {
			$q2=str_replace('#EXT#', 'e', $pgv_lang[$q2]);
		}
		break;
	default:
		if (isset($pgv_lang[$q2]))
			$q2=$pgv_lang[$q2];
		break;
	}
}

?>