]> git.mxchange.org Git - friendica.git/blob - mod/babel.php
Merge pull request #4312 from zeroadam/feature/L10n
[friendica.git] / mod / babel.php
1 <?php
2 /**
3  * @file mod/babel.php
4  */
5 use Friendica\Content\Text\Markdown;
6 use Friendica\Core\L10n;
7
8 require_once 'include/bbcode.php';
9 require_once 'include/bb2diaspora.php';
10 require_once 'include/html2bbcode.php';
11
12 function visible_lf($s)
13 {
14         return str_replace("\n", '<br />', $s);
15 }
16
17 function babel_content()
18 {
19         $o = '<h1>Babel Diagnostic</h1>';
20
21         $o .= '<form action="babel" method="post">';
22         $o .= L10n::t('Source (bbcode) text:') . EOL;
23         $o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
24         $o .= '<input type="submit" name="submit" value="Submit" /></form>';
25
26         $o .= '<br /><br />';
27
28         $o .= '<form action="babel" method="post">';
29         $o .= L10n::t('Source (Diaspora) text to convert to BBcode:') . EOL;
30         $o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
31         $o .= '<input type="submit" name="submit" value="Submit" /></form>';
32
33         $o .= '<br /><br />';
34
35         if (x($_REQUEST, 'text')) {
36                 $text = trim($_REQUEST['text']);
37                 $o .= '<h2>' . L10n::t('Source input: ') . '</h2>' . EOL . EOL;
38                 $o .= visible_lf($text) . EOL . EOL;
39
40                 $html = bbcode($text);
41                 $o .= '<h2>' . L10n::t('bbcode (raw HTML): ') . '</h2>' . EOL . EOL;
42                 $o .= htmlspecialchars($html) . EOL . EOL;
43
44                 //$html = bbcode($text);
45                 $o .= '<h2>' . L10n::t('bbcode: ') . '</h2>' . EOL . EOL;
46                 $o .= $html . EOL . EOL;
47
48                 $bbcode = html2bbcode($html);
49                 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
50                 $o .= visible_lf($bbcode) . EOL . EOL;
51
52                 $diaspora = bb2diaspora($text);
53                 $o .= '<h2>' . L10n::t('bb2diaspora: ') . '</h2>' . EOL . EOL;
54                 $o .= visible_lf($diaspora) . EOL . EOL;
55
56                 $html = Markdown::convert($diaspora);
57                 $o .= '<h2>' . L10n::t('bb2diaspora => Markdown: ') . '</h2>' . EOL . EOL;
58                 $o .= $html . EOL . EOL;
59
60                 $bbcode = diaspora2bb($diaspora);
61                 $o .= '<h2>' . L10n::t('bb2diaspora => diaspora2bb: ') . '</h2>' . EOL . EOL;
62                 $o .= visible_lf($bbcode) . EOL . EOL;
63
64                 $bbcode = html2bbcode($html);
65                 $o .= '<h2>' . L10n::t('bbcode => html2bbcode: ') . '</h2>' . EOL . EOL;
66                 $o .= visible_lf($bbcode) . EOL . EOL;
67         }
68
69         if (x($_REQUEST, 'd2bbtext')) {
70                 $d2bbtext = trim($_REQUEST['d2bbtext']);
71                 $o .= '<h2>' . L10n::t('Source input (Diaspora format): ') . '</h2>' . EOL . EOL;
72                 $o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
73
74                 $bb = diaspora2bb($d2bbtext);
75                 $o .= '<h2>' . L10n::t('diaspora2bb: ') . '</h2>' . EOL . EOL;
76                 $o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
77         }
78
79         return $o;
80 }