add en_CAT makefile and use ucfirst/ucwords
This commit is contained in:
parent
adc545a0cb
commit
4c8d58b646
19 changed files with 110 additions and 57 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/data
|
||||
/src/web/lang/en_CAT
|
||||
|
|
|
@ -11,7 +11,7 @@ class Modal_controller extends Controller {
|
|||
* @param array $data
|
||||
*/
|
||||
private function modal($name, $data = array()): void {
|
||||
$title = lang($name . '_modal_title');
|
||||
$title = ucwords(lang($name . '_modal_title'));
|
||||
$data['title'] = $title;
|
||||
$data['content'] = $name;
|
||||
$this->view('template/modal', $data);
|
||||
|
|
|
@ -7,7 +7,7 @@ class Auth_model extends Model {
|
|||
|
||||
public function get_data(): ?array {
|
||||
$data = parent::get_data();
|
||||
$data['title'] = lang('login');
|
||||
$data['title'] = ucfirst(lang('login'));
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ class Error_model extends Model {
|
|||
private function get_msg(&$data) {
|
||||
if (!array_key_exists('code', $_GET)) {
|
||||
http_response_code(500);
|
||||
$data['msg'] = lang('error');
|
||||
$data['msg'] = ucfirst(lang('error'));
|
||||
$data['title'] = '500';
|
||||
} else {
|
||||
$code = $_GET['code'];
|
||||
http_response_code($code);
|
||||
$data['title'] = $code;
|
||||
$msg = lang('error_' . $code, FALSE);
|
||||
$msg = ucfirst(lang('error_' . $code, FALSE));
|
||||
if (!$msg) {
|
||||
$msg = lang('error');
|
||||
$msg = ucfirst(lang('error'));
|
||||
}
|
||||
$data['msg'] = $msg;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class Home_model extends Model {
|
|||
|
||||
public function get_data(): ?array {
|
||||
$data = parent::get_data();
|
||||
$data['title'] = lang('title');
|
||||
$data['title'] = ucfirst(lang('title'));
|
||||
$data['posts'] = $this->get_posts();
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class People_model extends Model {
|
|||
|
||||
public function get_data(): ?array {
|
||||
$data = parent::get_data();
|
||||
$data['title'] = lang('title');
|
||||
$data['title'] = ucfirst(lang('title'));
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class Profile_model extends Model {
|
|||
$data['following'] = $following;
|
||||
$data['followed'] = $followed;
|
||||
$data['follow_id'] = $follow_id;
|
||||
$data['title'] = lang('title', sub: [$user['first_name']]);
|
||||
$data['title'] = ucfirst(lang('title', sub: [$user['first_name']]));
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div id="main-content">
|
||||
<div class="branding col">
|
||||
<h1>xssbook</h1>
|
||||
<span><?=lang('login_branding')?></span>
|
||||
<span><?=ucfirst(lang('login_branding'))?></span>
|
||||
</div>
|
||||
<div class="form card col">
|
||||
<form id="action-login" class="col" action="">
|
||||
|
@ -13,9 +13,10 @@
|
|||
name="username"
|
||||
id="login-username"
|
||||
placeholder=" "
|
||||
autofocus="true"
|
||||
>
|
||||
<label for="username">
|
||||
<?=lang('ph_username')?>
|
||||
<?=ucfirst(lang('ph_username'))?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rel mb">
|
||||
|
@ -26,7 +27,7 @@
|
|||
placeholder=" "
|
||||
>
|
||||
<label for="password">
|
||||
<?=lang('ph_password')?>
|
||||
<?=ucfirst(lang('ph_password'))?>
|
||||
</label>
|
||||
</div>
|
||||
<?=ilang('action_login',
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
<?php /* vi: syntax=php */ ?>
|
||||
<div id="main-content">
|
||||
<h1><?=$title?></h1>
|
||||
<span><?=$msg?></span>
|
||||
<span><?=ucfirst($msg)?></span>
|
||||
</div>
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
id="action-new-post"
|
||||
class="btn btn-alt btn-wide ml"
|
||||
autocomplete="off"
|
||||
aria-label="<?=lang('action_new_post_tip')?>"
|
||||
aria-label="<?=ucfirst(lang('action_new_post_tip'))?>"
|
||||
>
|
||||
<?=lang('action_new_post_text', sub: [$self['first_name']])?>
|
||||
<?=ucfirst(lang('action_new_post_text', sub: [$self['first_name']]))?>
|
||||
</a>
|
||||
</div>
|
||||
<script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
|
||||
<?php /* vi: syntax=php */ ?>
|
||||
<div id="main-content" class="col">
|
||||
<h1 class="title"><?=lang('title')?></h1>
|
||||
<h3 class="desc"><?=lang('desc')?></h3>
|
||||
<h1 class="title"><?=ucfirst(lang('title'))?></h1>
|
||||
<h3 class="desc"><?=ucfirst(lang('desc'))?></h3>
|
||||
<hr>
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
<div class="row grow">
|
||||
<div class="col">
|
||||
<strong class="name"><?=$this->format_model->name($user)?></strong>
|
||||
<span class="dim"><?=$user['follower_count'] . ' ' . lang('followers')?></span>
|
||||
<span class="dim"><?=$user['follower_count'] . ' ' . ucfirst(lang('followers'))?></span>
|
||||
</div>
|
||||
<?php if (!isset($self) || $self['id'] != $user['id']): ?>
|
||||
<?php if (
|
||||
$this->main->session &&
|
||||
(!isset($self) || $self['id'] != $user['id'])
|
||||
): ?>
|
||||
<div id="follow-container">
|
||||
<?=ilang(
|
||||
'action_follow',
|
||||
|
@ -120,7 +123,7 @@
|
|||
</div>
|
||||
<?php if(strlen($user['profile_bio']) > 0): ?>
|
||||
<br>
|
||||
<strong><?=lang('bio')?></strong>
|
||||
<strong><?=ucfirst(lang('bio'))?></strong>
|
||||
<span class="dim"><?=$user['profile_bio']?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
@ -158,53 +161,53 @@
|
|||
?>
|
||||
</div>
|
||||
<div id="tab-about" class="tab card">
|
||||
<h1><?=lang('about_general')?></h1>
|
||||
<h1><?=ucfirst(lang('about_general'))?></h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_general_username')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_general_username'))?></strong></td>
|
||||
<td><?=$user['username']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_general_full_name')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_general_full_name'))?></strong></td>
|
||||
<td><?=$user['first_name'] . ' ' . $user['last_name']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_general_email')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_general_email'))?></strong></td>
|
||||
<td><?=$user['email']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_general_gender')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_general_gender'))?></strong></td>
|
||||
<td><?=$user['gender']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_general_birth_date')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_general_birth_date'))?></strong></td>
|
||||
<td><?=$user['birth_date']?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h1><?=lang('about_stats')?></h1>
|
||||
<h1><?=ucfirst(lang('about_stats'))?></h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_stats_posts')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_stats_posts'))?></strong></td>
|
||||
<td><?=$user['post_count']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_stats_like')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_stats_like'))?></strong></td>
|
||||
<td><?=$user['like_count']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_stats_comments')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_stats_comments'))?></strong></td>
|
||||
<td><?=$user['comment_count']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_stats_following')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_stats_following'))?></strong></td>
|
||||
<td><?=$user['followed_count']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_stats_joined')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_stats_joined'))?></strong></td>
|
||||
<td><?=$user['created']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?=lang('about_stats_seen')?></strong></td>
|
||||
<td><strong><?=ucfirst(lang('about_stats_seen'))?></strong></td>
|
||||
<td><?=$user['seen']?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -13,19 +13,19 @@
|
|||
id="action-home"
|
||||
class="btn<?=$this->main->info['app'] == 'home' ? ' btn-blue btn-border' : ''?>"
|
||||
href="/home"
|
||||
title="<?=lang('action_home_tip')?>"
|
||||
title="<?=ucfirst(lang('action_home_tip'))?>"
|
||||
>
|
||||
<i class="mi mi-lg">home</i>
|
||||
<span><?=lang('action_home_text')?></span>
|
||||
<span><?=ucfirst(lang('action_home_text'))?></span>
|
||||
</a>
|
||||
<a
|
||||
id="action-people"
|
||||
class="btn<?=$this->main->info['app'] == 'people' ? ' btn-blue btn-border' : ''?>"
|
||||
href="/people"
|
||||
title="<?=lang('action_people_tip')?>"
|
||||
title="<?=ucfirst(lang('action_people_tip'))?>"
|
||||
>
|
||||
<i class="mi mi-lg">people</i>
|
||||
<span><?=lang('action_people_text')?></span>
|
||||
<span><?=ucfirst(lang('action_people_text'))?></span>
|
||||
</a>
|
||||
<!--a
|
||||
id="action-chat"
|
||||
|
@ -40,7 +40,7 @@
|
|||
<div class="nav-right">
|
||||
<button
|
||||
id="action-hamburger"
|
||||
title="<?=lang('action_hamburger_tip')?>"
|
||||
title="<?=ucfirst(lang('action_hamburger_tip'))?>"
|
||||
class="btn mr"
|
||||
>
|
||||
<i class="mi mi-lg">menu</i>
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
<?=pfp($user)?>
|
||||
<div class="col ml">
|
||||
<strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
|
||||
<span class="dim"><?=lang('now')?></span>
|
||||
<span class="dim"><?=ucfirst(lang('now'))?></span>
|
||||
</div>
|
||||
</div>
|
||||
<textarea
|
||||
type="text"
|
||||
name="content"
|
||||
id="new-post-content"
|
||||
placeholder="<?=lang('action_new_post_text', sub: [$user['first_name']])?>"
|
||||
placeholder="<?=ucfirst(lang('action_new_post_text', sub: [$user['first_name']]))?>"
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<form id="register-form">
|
||||
<div class="modal-content register-modal col">
|
||||
<label class="static">
|
||||
<?=lang('ph_basic_info')?>
|
||||
<?=ucwords(lang('ph_basic_info'))?>
|
||||
</label>
|
||||
<div class="row mt">
|
||||
<div class="rel btn-wide">
|
||||
|
@ -15,7 +15,7 @@
|
|||
placeholder=" "
|
||||
>
|
||||
<label for="first_name">
|
||||
<?=lang('ph_first_name')?>
|
||||
<?=ucwords(lang('ph_first_name'))?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rel ml btn-wide">
|
||||
|
@ -26,7 +26,7 @@
|
|||
placeholder=" "
|
||||
>
|
||||
<label for="last_name">
|
||||
<?=lang('ph_last_name')?>
|
||||
<?=ucwords(lang('ph_last_name'))?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -38,7 +38,7 @@
|
|||
placeholder=" "
|
||||
>
|
||||
<label for="username">
|
||||
<?=lang('ph_username')?>
|
||||
<?=ucwords(lang('ph_username'))?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rel mt">
|
||||
|
@ -49,7 +49,7 @@
|
|||
placeholder=" "
|
||||
>
|
||||
<label for="password">
|
||||
<?=lang('ph_password')?>
|
||||
<?=ucwords(lang('ph_password'))?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rel mt">
|
||||
|
@ -60,11 +60,11 @@
|
|||
placeholder=" "
|
||||
>
|
||||
<label for="email">
|
||||
<?=lang('ph_email')?>
|
||||
<?=ucwords(lang('ph_email'))?>
|
||||
</label>
|
||||
</div>
|
||||
<label for="birth_date" class="mt static">
|
||||
<?=lang('ph_birth_date')?>
|
||||
<?=ucwords(lang('ph_birth_date'))?>
|
||||
</label>
|
||||
<input
|
||||
class="mt"
|
||||
|
@ -73,7 +73,7 @@
|
|||
id="register-birth-date"
|
||||
>
|
||||
<label for="gender" class="mt static">
|
||||
<?=lang('ph_gender')?>
|
||||
<?=ucwords(lang('ph_gender'))?>
|
||||
</label>
|
||||
<div class="row mt" data-type="radio" data-name="gender-wrapper">
|
||||
<div class="rel radio mr">
|
||||
|
@ -81,13 +81,13 @@
|
|||
type="radio"
|
||||
id="register-gender-male"
|
||||
name="gender"
|
||||
value="male"
|
||||
value="Male"
|
||||
>
|
||||
<label
|
||||
for="register-gender-male"
|
||||
class="static"
|
||||
>
|
||||
<?=lang('ph_gender_male')?>
|
||||
<?=ucwords(lang('ph_gender_male'))?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rel radio mr">
|
||||
|
@ -95,13 +95,13 @@
|
|||
type="radio"
|
||||
id="register-gender-female"
|
||||
name="gender"
|
||||
value="female"
|
||||
value="Female"
|
||||
>
|
||||
<label
|
||||
for="register-gender-female"
|
||||
class="static"
|
||||
>
|
||||
<?=lang('ph_gender_female')?>
|
||||
<?=ucwords(lang('ph_gender_female'))?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rel radio">
|
||||
|
@ -109,13 +109,13 @@
|
|||
type="radio"
|
||||
id="register-gender-lettuce"
|
||||
name="gender"
|
||||
value="lettuce"
|
||||
value="Lettuce"
|
||||
>
|
||||
<label
|
||||
for="register-gender-lettuce"
|
||||
class="static"
|
||||
>
|
||||
<?=lang('ph_gender_lettuce')?>
|
||||
<?=ucwords(lang('ph_gender_lettuce'))?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
$post_attrs['likeId'] = $post['like_id'];
|
||||
}
|
||||
?>
|
||||
<span class="likes dim"><span class="count"><?=$post['like_count']?></span><?=' ' . lang('likes')?></span>
|
||||
<span class="likes dim"><span class="count"><?=$post['like_count']?></span><?=' ' . ucfirst(lang('likes'))?></span>
|
||||
<?php if ($self): ?>
|
||||
<hr>
|
||||
<div class="row">
|
||||
|
@ -76,8 +76,8 @@
|
|||
autocomplete="off"
|
||||
type="text"
|
||||
name="text"
|
||||
placeholder="<?=lang('action_new_comment_text')?>"
|
||||
aria-label="<?=lang('action_new_comment_tip')?>"
|
||||
placeholder="<?=ucfirst(lang('action_new_comment_text'))?>"
|
||||
aria-label="<?=ucfirst(lang('action_new_comment_tip'))?>"
|
||||
>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -26,7 +26,7 @@ function ilang($key,
|
|||
$sub = NULL,
|
||||
$button = FALSE,
|
||||
) {
|
||||
$text = lang($key . "_text", FALSE, sub: $sub);
|
||||
$text = ucfirst(lang($key . "_text", FALSE, sub: $sub));
|
||||
$tip = lang($key . "_tip", FALSE, sub: $sub);
|
||||
$icon = lang($key . "_icon", FALSE);
|
||||
$content = lang($key . "_content", FALSE);
|
||||
|
|
19
src/web/lang/Makefile
Normal file
19
src/web/lang/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# en_CAT generator from en_US
|
||||
# uwuify and awk required
|
||||
#
|
||||
|
||||
LANG_SRC = $(shell find en_US -type f)
|
||||
LANG_OBJ = $(patsubst en_US/%,en_CAT/%,$(LANG_SRC))
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: $(LANG_OBJ)
|
||||
|
||||
$(LANG_OBJ): en_CAT/% : en_US/%
|
||||
@printf "\033[35m UWU \033[0m%s\n" $<
|
||||
@mkdir -p $(@D)
|
||||
@./_bin/transpile.sh $< $@
|
||||
|
||||
clean:
|
||||
@rm -fr "en_CAT"
|
29
src/web/lang/_bin/transpile.sh
Executable file
29
src/web/lang/_bin/transpile.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
|
||||
lang_part() {
|
||||
echo "$1" | awk "{split(\$0,a,\" = \"); print a[$2]}"
|
||||
}
|
||||
export -f lang_part
|
||||
|
||||
handle_line() {
|
||||
line="$1"
|
||||
left=$(lang_part "$line" 1)
|
||||
right=$(lang_part "$line" 2)
|
||||
echo "$left" | grep -Ev '_content|_line' > /dev/null
|
||||
if [ "$?" -eq 0 ]; then
|
||||
right=$(echo "$right" | uwuify)
|
||||
fi;
|
||||
right=${right%;};
|
||||
echo "$left = $right;"
|
||||
}
|
||||
export -f handle_line
|
||||
|
||||
transpile() {
|
||||
file="$1"
|
||||
out="$2"
|
||||
printf "" > "$out"
|
||||
printf "<?php /* Copyright (c) 2024 Freya Murphy */\n\n" > "$out";
|
||||
cat "$file" | grep '$lang' | xargs -d'\n' -I {} bash -c 'handle_line "$@"' _ {} >> "$out"
|
||||
}
|
||||
|
||||
transpile "$1" "$2"
|
Loading…
Reference in a new issue