diff options
author | Freya Murphy <freya@freyacat.org> | 2024-04-05 15:00:27 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-04-05 15:00:27 -0400 |
commit | 4c8d58b646ac62e67fc34c12f8cad51e7512bee3 (patch) | |
tree | 432351cce0acccd9a986872f7ea020dae14b0c71 /src | |
parent | user menu (diff) | |
download | xssbook2-4c8d58b646ac62e67fc34c12f8cad51e7512bee3.tar.gz xssbook2-4c8d58b646ac62e67fc34c12f8cad51e7512bee3.tar.bz2 xssbook2-4c8d58b646ac62e67fc34c12f8cad51e7512bee3.zip |
add en_CAT makefile and use ucfirst/ucwords
Diffstat (limited to 'src')
-rw-r--r-- | src/web/_controller/modal.php | 2 | ||||
-rw-r--r-- | src/web/_model/apps/auth.php | 2 | ||||
-rw-r--r-- | src/web/_model/apps/error.php | 6 | ||||
-rw-r--r-- | src/web/_model/apps/home.php | 2 | ||||
-rw-r--r-- | src/web/_model/apps/people.php | 2 | ||||
-rw-r--r-- | src/web/_model/apps/profile.php | 2 | ||||
-rw-r--r-- | src/web/_views/apps/auth/login.php | 7 | ||||
-rw-r--r-- | src/web/_views/apps/error/main.php | 2 | ||||
-rw-r--r-- | src/web/_views/apps/home/main.php | 4 | ||||
-rw-r--r-- | src/web/_views/apps/people/header.php | 4 | ||||
-rw-r--r-- | src/web/_views/apps/profile/main.php | 35 | ||||
-rw-r--r-- | src/web/_views/header.php | 10 | ||||
-rw-r--r-- | src/web/_views/modal/new_post.php | 4 | ||||
-rw-r--r-- | src/web/_views/modal/register.php | 28 | ||||
-rw-r--r-- | src/web/_views/template/post.php | 6 | ||||
-rw-r--r-- | src/web/helper/lang.php | 2 | ||||
-rw-r--r-- | src/web/lang/Makefile | 19 | ||||
-rwxr-xr-x | src/web/lang/_bin/transpile.sh | 29 |
18 files changed, 109 insertions, 57 deletions
diff --git a/src/web/_controller/modal.php b/src/web/_controller/modal.php index 03074d4..40a2b42 100644 --- a/src/web/_controller/modal.php +++ b/src/web/_controller/modal.php @@ -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); diff --git a/src/web/_model/apps/auth.php b/src/web/_model/apps/auth.php index 8a359d5..c528601 100644 --- a/src/web/_model/apps/auth.php +++ b/src/web/_model/apps/auth.php @@ -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; } } diff --git a/src/web/_model/apps/error.php b/src/web/_model/apps/error.php index 4118c62..0a08fdd 100644 --- a/src/web/_model/apps/error.php +++ b/src/web/_model/apps/error.php @@ -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; } diff --git a/src/web/_model/apps/home.php b/src/web/_model/apps/home.php index caa254f..3ca7fb4 100644 --- a/src/web/_model/apps/home.php +++ b/src/web/_model/apps/home.php @@ -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; } diff --git a/src/web/_model/apps/people.php b/src/web/_model/apps/people.php index 4287094..4125dad 100644 --- a/src/web/_model/apps/people.php +++ b/src/web/_model/apps/people.php @@ -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; } } diff --git a/src/web/_model/apps/profile.php b/src/web/_model/apps/profile.php index 97b0150..16765d9 100644 --- a/src/web/_model/apps/profile.php +++ b/src/web/_model/apps/profile.php @@ -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; } } diff --git a/src/web/_views/apps/auth/login.php b/src/web/_views/apps/auth/login.php index 2ba0896..c12af57 100644 --- a/src/web/_views/apps/auth/login.php +++ b/src/web/_views/apps/auth/login.php @@ -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', diff --git a/src/web/_views/apps/error/main.php b/src/web/_views/apps/error/main.php index dde39cf..6d7e2ea 100644 --- a/src/web/_views/apps/error/main.php +++ b/src/web/_views/apps/error/main.php @@ -2,5 +2,5 @@ <?php /* vi: syntax=php */ ?> <div id="main-content"> <h1><?=$title?></h1> - <span><?=$msg?></span> + <span><?=ucfirst($msg)?></span> </div> diff --git a/src/web/_views/apps/home/main.php b/src/web/_views/apps/home/main.php index 60c3eb9..6112173 100644 --- a/src/web/_views/apps/home/main.php +++ b/src/web/_views/apps/home/main.php @@ -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> diff --git a/src/web/_views/apps/people/header.php b/src/web/_views/apps/people/header.php index 7f3d95b..1f3a025 100644 --- a/src/web/_views/apps/people/header.php +++ b/src/web/_views/apps/people/header.php @@ -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> diff --git a/src/web/_views/apps/profile/main.php b/src/web/_views/apps/profile/main.php index 6671d87..919b190 100644 --- a/src/web/_views/apps/profile/main.php +++ b/src/web/_views/apps/profile/main.php @@ -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> diff --git a/src/web/_views/header.php b/src/web/_views/header.php index 71607d5..97eb435 100644 --- a/src/web/_views/header.php +++ b/src/web/_views/header.php @@ -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> diff --git a/src/web/_views/modal/new_post.php b/src/web/_views/modal/new_post.php index 15163c9..c9e9c7f 100644 --- a/src/web/_views/modal/new_post.php +++ b/src/web/_views/modal/new_post.php @@ -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"> diff --git a/src/web/_views/modal/register.php b/src/web/_views/modal/register.php index 1949dd3..a6a2f1f 100644 --- a/src/web/_views/modal/register.php +++ b/src/web/_views/modal/register.php @@ -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> diff --git a/src/web/_views/template/post.php b/src/web/_views/template/post.php index fb8cef5..3dcae8f 100644 --- a/src/web/_views/template/post.php +++ b/src/web/_views/template/post.php @@ -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> diff --git a/src/web/helper/lang.php b/src/web/helper/lang.php index b0638a6..f7d69e6 100644 --- a/src/web/helper/lang.php +++ b/src/web/helper/lang.php @@ -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); diff --git a/src/web/lang/Makefile b/src/web/lang/Makefile new file mode 100644 index 0000000..fd4ca9c --- /dev/null +++ b/src/web/lang/Makefile @@ -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" diff --git a/src/web/lang/_bin/transpile.sh b/src/web/lang/_bin/transpile.sh new file mode 100755 index 0000000..18bb4c4 --- /dev/null +++ b/src/web/lang/_bin/transpile.sh @@ -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" |