diff --git a/autoload.php b/autoload.php index 7c2c1c78..e79cdbe1 100644 --- a/autoload.php +++ b/autoload.php @@ -24,7 +24,7 @@ class Autoloader public static function reload($reload = false) { - $key = 'lbry-classes-4'; + $key = 'lbry-classes-5'; if (ini_get('apc.enabled') && !$reload) { $classes = apc_fetch($key, $success); diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index dd315a68..bf3c55fc 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -22,11 +22,12 @@ class DownloadActions extends Actions public static function executeGet() { $email = static::param('e'); + $user = []; + if ($email) { $emailIsValid = filter_var($email, FILTER_VALIDATE_EMAIL); - $user = []; if ($emailIsValid) { $user = Prefinery::findUser($email); diff --git a/data/i18n/en.yaml b/data/i18n/en.yaml new file mode 100644 index 00000000..a2acef52 --- /dev/null +++ b/data/i18n/en.yaml @@ -0,0 +1,229 @@ +# This file contains the text of the LBRY website, organized with labels. +# Text segments are organized hierarchically. For any given language, the user's +# browser will look at the corresponding language file for the appropriate label +# and render the segment in the correct language. +# For example, global.tagline renders as "Play, Share, Earn" if the user's langu +# age settings are set to English, and the same label renders as "Assista, Compa +# rtilhe, Ganhe" if the user's settings are set to Portuguese. +# +# + +description: + allowed: Download/install the latest version of LBRY for %os%. + faq: Frequently asked questions about LBRY. + get: Download/install the latest version of LBRY. + home: Meet LBRY, a content sharing and publishing platform that is decentralized and owned by its users. + join: Follow along and receive updates about LBRY via email. + learn: Learn more about LBRY, the technology that puts you back in control of the internet. + news: Access information and content in ways you never dreamed possible. Earn credits for your unused bandwidth and diskspace. + no-os: Download or install the latest version of LBRY. + press: LBRY Press Kit. Information and media for those who want to report on LBRY. + publish: Publish your content on the world's first platform that leaves creators in control. + team: LBRY is founded by a team passionate about connecting producers and consumers and breaking down broken models. Learn more about them. + test: WHAT WHAT + what: Access information and content in ways you never dreamed possible. Earn credits for your unused bandwidth and diskspace. +download: + beta: This is still a beta. + creator: Creator? Skip the Line + credits: Claim Credits + curse: While LBRY is now live, it may crash, work unreliably, or inadvertently put a curse on your family for generations (a common programming error). Use at your own risk. + deb: Download .deb + earn1: Earn + # this many credits + earn2: for completing the survey below after install. + email1: After download, use email + email2: and the code you received via email to receive your credits. + email3: If you received a printed code and it does not work after you download, check your email for a different code. + for-os: LBRY for %os% + github: Or, view the source and compile instructions on + osx: Arrival is expected by July 5. + osx2: Download for OS X + other: Other Systems + popular: Popular publishers can earn $1,000 and early access for publishing via LBRY. + select: Select an OS + signup: LBRY is currently in invite only mode. Enter your email to join the waitlist, or your email and invite code for access. + unavailable: LBRY is not yet out on your platform. You will receive an email as we expand LBRY to your preferred platform. + verb: Download + windows: Arrival is expected this month. + works: "Works with Ubuntu, Debian, or any distro with apt or dpkg." +email: + address: Email + code: Invite Code + disclaimer: You will receive 1-2 messages a month, only from LBRY, Inc. and only about LBRY. You can easily unsubscribe at any time. + go: Go + nocode: None, but I want in as soon as possible! + placeholder: someone@somewhere.com + subs: Subscribe + subscribe: Subscribe to our email list + updates: Get Updates + yescode: "Yes" +global: + get: Get LBRY + learn: Learn More + sentence: Watch, read and play in a decentralized digital library controlled by the community. + tagline: Play, Share, Earn. +learn: + 100: LBRY in 100 Seconds + art: Art in the Internet Age + essay: Read the Essay + exchange: Bittrex Exchange + explore: Explore + explorer: Block Explorer + how: Learn how LBRY will forever improve how we create and share with one another. + join: Join Us + nerd: Nerd Out + rebels: Learn more about the relentless rebels changing the internet. + team: About The Team +nav: + get: Get + home: Home + learn: Learn + news: News +news: + # It is worth noting other languages use different date formats. + author: Author + desk: The Front Desk + musings: News and musings from the LBRY team. + next: Next + prev: Previous +page: + faq: + back: Back to FAQ + header: Frequently Asked Questions + funnier: One day this will be funnier but today is not that day. + join: Join Email List + refer: + count0: Don't fret, we still like you. + count1: Great start! Thanks for sharing. + count2: Well done! Thank you. + count3: You are really doing your part! Amazing. + count4: You are an elite LBRY sharer. Thank you much! + # earn1 and earn2 form a sentence with a number between them: + earn1: Earn + # this many credits + earn2: "for each user who joins via this URL:" + # The whole sentence should make sense, even if each of these segments are n + # ot translated literally. + # This might be the case if required by the syntax of the translated languag + # e. + more: more on referrals + referone: 1 LBRYian has joined because of you. + refermany: %count% LBRYians have joined because of you. + status: Your Sharing Status + zero: Zero + notfound: Page Not Found + team: + advisory: Advisory Team + alex: + parag1: Alex Tabarrok is Bartley J. Madden Chair in Economics at the Mercatus Center and a professor of economics at George Mason University. He specializes in intellectual property reform, the effectiveness of markets, and the justice system. + parag2: Tabarrok is the coauthor, with Mercatus colleague Tyler Cowen, of the popular economics blog Marginal Revolution and cofounder of the online educational platform Marginal Revolution University. He is the coauthor of Modern Principles of Economics, and author of the recent book Launching the Innovation Renaissance. His articles have appeared in the New York Times, the Washington Post, the Wall Street Journal, and many other prestigious publications. + parag3: Tabarrok received his PhD in economics from George Mason University. + title: Economic Advisor + grin: + parag1: One of Alex's job titles is Wizard, so named because he can seemingly understand and utilize new technologies faster than they can be created. + parag2: Alex designs and manages scalable infrastructure solutions for SaaS firms, and is leveraging that experience to ensure LBRY's architecture is rock-solid. + parag3: Alex is the 3rd dual-degree graduate from RPI on this team, receiving degrees in Computer Science and Psychology. He is also an alumni of Stuyvesant High School. + title: Founder, Chief Infrastructure Officer + header: The Team + jack: + parag1: Jack's path to developer with LBRY is fairly typical() face sixty years in prison for innocent chemistry experiments; lose interest in chemistry; program insane electric guitars for Kiss; decide to revolutionize the internet. + parag2: Jack was one of the first people to discover LBRY and took to it so fast he may understand more about it than anyone. + parag3: Jack has Asperger's Syndrome and is actively involved in the autism community. He was a regular on Wrong Planet's Autism Talk TV, has appeared on National Public Radio, the New York Times, and presents around the country. + title: Founder, Core Developer + jeremy: + parag1: Jeremy knows how to build and scale a startup starting from day one. He knows how to deliver usable products and get those products in front of the right people. + parag2: Jeremy is responsible for the packing, presentation, and strategy of LBRY, as well as some design aspects. He is a longtime BitTorrent community enthusiast. + parag3: Jeremy founded TopScore, a startup that processes millions of dollars monthly in event and activity registrations. He also attended Rensselaer Polytechnic Institute, where he received degrees in physics and computer science. + title: Founder, Chief Executive Officer + jimmy: + parag1: Jimmy is the second member of team LBRY to graduate from Rensselaer with degrees in computer science and physics. After, he found himself mired in government bureaucracy, spending too much time to get too little done. + parag2: Ready to work on a project he believed in, Jimmy left a national security programming job to start LBRY. Jimmy created the LBRY protocol and the first LBRY application. + parag3: Jimmy is a Bitcoin fanatic and has been since its early days. He has long been interested in the benefits of decentralization. + title: Founder, Chief Product Officer + josh: + parag1: Josh's combination of an MBA, strong analytical skills, programming skills, advertising expertise, and a perceptive insight to financial markets lead him to frequently bear the only title that can summarize such diverse wizardry () problem solver. + parag2: Josh has founded innovative financial companies (later acquired), run millions of dollars in Adwords campaigns, and been an early actor in other crypto projects. Josh's contributions to LBRY will be as diverse as his background. + title: Founder, Chief Operations & Growth Officer + michael: + parag1: Michael Huemer is Professor of Philosophy and Ethics at the University of Colorado, where he has taught since 1998. He has published three single-author scholarly books (including Ethical Intuitionism), one edited anthology, and more than fifty academic articles in epistemology, ethics, political philosophy, and metaphysics. + parag2: Huemer's articles have appeared in such journals as the Philosophical Review, Mind, the Journal of Philosophy, Ethics, and others. His materials are used as readings in classrooms nationwide. He received a B.A. from UC Berkeley and a Ph.D. from Rutgers University. + title: Ethical Advisor + mike: + parag1: With a humble BA in Philosophy from Tulane University, Mike has built a successful financial services marketing company, Centinel Consulting. Centinel has helped clients grow from close to nothing to hundreds of thousands of visitors. He manages email marketing lists and social media accounts of the same size. + parag2: Mike has been involved with the Bitcoin community since the early days. His friends have launched companies like Lamassu BTM, Coinapult, Shapeshift. Now, he's ready to change the world by harnessing blockchain technology. Mike heads up LBRY's marketing efforts and serves as an ambassador for our platform to media, investors, and the public. + title: Founder, Evangelist + people: LBRY is made possible by more people than we could ever list here. The founding team is listed below. + stephan: + parag1: Stephan Kinsella is a registered patent attorney and has over twenty years' experience in patent, intellectual property, and general commercial and corporate law. He is the founder and director of the Center for the Study of Innovative Freedom. Kinsella has published numerous articles and books on intellectual property law and legal topics including International Investment, Political Risk, and Dispute Resolution() A Practitioner's Guide and Against Intellectual Property. + parag2: He received an LL.M. in international business law from King's College London, a JD from the Paul M. Hebert Law Center at Lousiana State University, as well as BSEE and MSEE degrees. His websites are stephankinsella.com and kinsellalaw.com + title: Legal Advisor + you: + advheader: Technical or Media Advisor + advtext: LBRY is seeking an extremely experienced technical advisor or an advisor with a strong background in the publishing and media space. If you're that person or have a suggestion, let us know. + header: You + parag1: Do you think opening up information would facilitate human flourishing? Do you want to join a bright core of people with an obsession for upending broken systems? Say hello. + title: Developer, Designer, Economist, Marketer, Investor, ??? + zargham: + parag1: Michael has spent years managing, designing, and overseeing a data science team and framework used to make multi-million dollar purchasing decisions for a large media company. He brings knowledge of the media distribution business, software development expertise, business development experience, technical skill and a network of corporate contacts. + parag2: Michael's ability to rapidly adapt new skill sets makes him a technical and business pocketknife of our startup team. He has a PhD in systems engineering from the University of Pennsylvania, with a focus on distributed systems. + title: Founder, Chief Technical Officer + updates: Join our email list and receive updates about LBRY via email. +press: + advisory: Advisory Team + archive: Download Media Archive + includes: This archive includes all logos, screenshots, and bios, but does not include all text on this page. + info: Information and media for those who want to write or report on LBRY. + title: LBRY Press Kit + logos: Logos and Product Images + team: Founding Team + used: Any information or media on this page or in our kit can be re-used or otherwise published without attribution. + zip: Download ZIP +publish: + abundance: Experience digital abundance. + allow: Allowance for us to promote availability of your content. + control: Complete Creator Control + credits: Receive $1,000 worth of LBRY credits to hold, use or sell. + earn: "Earn $1,000 and join the next content epoch: the viewer and you, with nobody in between." + feature: Content featured on the LBRY landing screen seen by all users, as well as on our blog, social media, and 100,000 person email list, including links to your YouTube or other profiles. + hand: We hold your hand every step of the way while taking none of your revenue. + how: How It Works + keepl: Keep Learning + keepr: Keep Reading + loading: Loading... + mention: A single social media mention about your availability on LBRY. + next: What's Next? + now: Get In Now + onlbry: Publish on LBRY + open: Open, Trustworthy Technology + partner: Publishing Partnership + premier: Premier Partner status. Receive insider access and support for life. + profit: More, Better Profit + questions: Questions? + quote: You was inspired by the world; allow the world to be inspired by [you] + upload: Upload five videos via the LBRY interface (we'll help you out). + watch: Watch "LBRY in 100 Seconds", an introduction to the wonderful technology of LBRY. + what: What is LBRY? + why: Why LBRY? + youget: What You Get + yougive: What You Give +rss: + description: Recent news about LBRY + lang: en + title: LBRY News +social: + also: Also On + github: GitHub (source code) + header: Build With Us + humansheader: Humans + humanstext: Let's create a freer, more creative world. + robotsheader: Wanna Be Robots + robotstext: Make with us. All LBRY code is open source. + slack: Slack (chat) + tweets: Tweets by @LBRYio +title: + home: LBRY - Play, Share, Earn + join: Join LBRY Email List + learn: Learn About LBRY + publish: Publish + refer: Share and Earn + what: "Art in the Internet Age: An Introduction to LBRY" \ No newline at end of file diff --git a/data/i18n/pt.yaml b/data/i18n/pt.yaml new file mode 100644 index 00000000..589c0731 --- /dev/null +++ b/data/i18n/pt.yaml @@ -0,0 +1,89 @@ +# I'm inserting ten lines of comments here just so that line numbers align with +# en.yaml. +# +# +# +# +# +# +# + +global: + tagline: Assista, Compartilhe, Ganhe. + sentence: Acesse vídeo, texto e música numa biblioteca digital descentralizada e controlada pela comunidade. +title: + home: LBRY - Assista, Compartilhe, Ganhe +description: + home: Conheça o LBRY - a plataforma de publicação e compartilhamento de conteúdo descentralizada e controlada pelos usuários. + faq: Perguntas frequentes sobre o LBRY. + news: Acesse informação e conteúdo de maneiras que você nunca imaginou. Ganhe créditos pela conexão e espaço em disco que você não usa. + what: Acesse informação e conteúdo de maneiras que você nunca imaginou. Ganhe créditos pela conexão e espaço em disco que você não usa. + team: O LBRY foi fundado por uma equipe apaixonada por conectar produtores e consumidores e acabar com sistemas disfuncionais. Saiba mais sobre eles. +email: + disclaimer: Você receberá 1 ou 2 mensagens por mês, enviadas somente pela LBRY Inc. e somente sobre o LBRY. É fácil cancelar sua assinatura a qualquer momento. +page: + home: + primary_button: Baixe o LBRY + learn_button: Saiba Mais + faq: + header: Perguntas Frequentes (FAQ) + team: + header: O Time + people: Muitas pessoas - mais do que nós conseguiríamos listar aqui - fazem o LBRY acontecer. Abaixo, o time de fundadores. + jeremy: + title: Fundador e Diretor Executivo (CEO) + parag1: Jeremy sabe fazer uma empresa startup crescer desde o primeiro dia. Ele sabe criar produtos fáceis de usar, e sabe levá-los às pessoas certas. + parag2: Sua atribuição é a apresentação, "embalagem" e estratégia do LBRY, junto com alguns aspectos do design. Ele é um fã de longa data da comunidade do BitTorrent. + parag3: Ele fundou a TopScore, uma startup que processa inscrições para eventos e atividades no valor de milhões de dólares por mês. É formado pelo Instituto Politécnico Rensselaer, com diplomas em Física e Ciência da Computação. + zargham: + title: Fundador e Diretor Técnico (CTO) + parag1: Michael tem anos de experiência na gestão, projeto e supervisão do sistema e da equipe de análise de dados usados por uma grande empresa de mídia para tomar decisões de compra multimilionárias. Ele traz consigo seu conhecimento do ramo de distribuição de mídia, especialidade em desenvolvimento de software, experiência no desenvolvimento de negócios, habilidades técnicas e uma rede de contatos empresariais. + parag2: Sua capacidade de se adaptar rapidamente a novas habilidades o faz um canivete suíço da tecnologia e dos negócios na nossa startup. Ele é PhD em Engenharia de Sistemas pela Universidade da Pensilvânia, com concentração em sistemas distribuídos. + josh: + title: Fundador e Diretor de Operações e Crescimento (COO) + parag1: "Josh combina um MBA, forte capacidade analítica, conhecimento em programação, experiência em publicidade e uma afiada percepção de mercados financeiros; por isso, com frequência ele recebe o único título que resume toda a sua mágica: o de resolvedor de problemas." + parag2: Ele fundou empresas financeiras inovadoras (posteriormente vendidas), gerenciou campanhas milionárias no Adwords, e foi um pioneiro em outros projetos envolvendo criptografia. Suas contribuições ao LBRY serão tão diversas quanto seu histórico. + jimmy: + title: Fundador e Diretor de Produto (CPO) + parag1: Jimmy é o segundo membro do Time LBRY a estudar Ciência da Computação e Física no Instituto Rensselaer. Após se formar, ele se viu atolado em burocracia do governo, gastando tempo demais e realizando de menos. + parag2: Pronto para trabalhar num projeto no qual acredita, Jimmy deixou um emprego de programador na área de segurança nacional para dar início ao LBRY. Ele criou o protocolo e o primeiro aplicativo do LBRY. + parag3: Jimmy é fanático por Bitcoin desde os primeiros dias. Há tempos ele se interessa pelos benefícios da descentralização. + mike: + title: Fundador e Divulgador + parag1: Com um humilde Bacharelado em Filosofia pela Universidade Tulane, Mike construiu uma bem-sucedida empresa de marketing de serviços financeiros, a Centinel Consulting. A Centinel ajuda seus clientes a crescer de quase nenhum até centenas de milhares de visitantes. Mike gerencia listas de marketing e contas de redes sociais da mesma envergadura. + parag2: Seu envolvimento com a comunidade do Bitcoin vem dos primeiros dias. Amigos de Mike criaram empresas como a Lamassu BTM, a Coinapult e o Shapeshift. Agora, ele está pronto para mudar o mundo usando a tecnologia da blockchain. Mike comanda as atividades de marketing do LBRY e atua como embaixador de nossa plataforma para a mídia, investidores e o público. + grin: + title: Fundador e Diretor de Infraestrutura + parag1: Um dos cargos de Alex é "Bruxo", porque, ao que parece, ele consegue entender e usar novas tecnologias mais rápido do que elas são criadas.https://www.google.com/search?q=CIO&oq=CIO&aqs=chrome..69i57j0l5.429j0j7&sourceid=chrome&ie=UTF-8#q=expans%C3%ADvel + parag2: Ele projeta e gerencia soluções de infraestrutura expansíveis para empresas de software como serviço (Saas); sua experiência ajuda a garantir que a arquitetura do LBRY é firme como uma rocha. + parag3: Ele é o terceiro desta lista a ter dois diplomas do IPR - graduou-se em Ciência da Computação e Psicologia. No ensino médio, cursou o prestigioso Colégio Stuyvesant, em Nova York. + jack: + title: Fundador e Desenvolvedor Principal + parag1: O percurso de Jack até se tornar o desenvolvedor do LBRY é bastante comum () ele correu o risco de passar 60 anos na cadeia por inocentes experimentos químicos; perdeu o interesse em química; programou guitarras animais para a banda Kiss; e decidiu revolucionar a Internet. + parag2: Jack foi um dos primeiros a descobrir o LBRY e o absorveu tão rápido que ele pode ser quem mais entende do assunto. + parag3: Ele tem a síndrome de Asperger e se envolve ativamente na comunidade do autismo. Ele aparecia regularmente no programa 'Autism Talk TV', do site 'Wrong Planet', apareceu na National Public Radio e no New York Times e dá palestras por todo o país. + you: + header: Você + title: Desenvolvedor, Designer, Economista, Marqueteiro, Investidor, ??? + parag1: Você acredita que facilitar o acesso à informação promoveria o desenvolvimento humano? Você quer entrar para um núcleo de pessoas brilhantes obcecadas por arrasar sistemas obsoletos? Diga oi. + advheader: Conselheiro Técnico ou de MídiaA + advtext: O LBRY busca um conselheiro técnico extremamente experiente ou um consultor com uma trajetória robusta em mídia e editoração. Se você é essa pessoa, ou se tem uma sugestão, escreva para a gente. + advisory: Time de Conselheiros + alex: + title: Conselheiro Econômico + parag1: Alex Tabarrok é o titular da Cátedra de Economia Bartley J. Madden no Centro Mercatus e professor de economia na Universidade George Mason. Sua especialidade é a reforma da legislação de propriedade intelectual, a eficácia dos mercados e o sistema de justiça. + parag2: Junto com seu colega de Mercatus Tyler Cowen, ele é coautor do renomado blog de economiaMarginal Revolution e cofundador da plataforma educacional digital Marginal Revolution University. É coautor do livro Modern Principles of Economics, e autor do recente Launching the Innovation Renaissance. Teve artigos publicados no New York Times, Washington Post, Wall Street Journal e muitos outros periódicos de prestígio. + parag3: Tabarrok é PhD em economia pela Universidade George Mason. + stephan: + title: Conselheiro Jurídico + parag1: Stephan Kinsella é advogado de patentes e tem mais de 20 anos de experiência em Direito das Patentes, propriedade intelectual, e Direito Comercial e Empresarial em geral. É fundador e diretor do Centro de Estudos da Liberdade de Inovação. Kinsella publicou numerosos artigos e livros sobre o Direito da propriedade intelectual e temas jurídicos, a exemplo de International Investment, Political Risk, and Dispute Resolution() A Practitioner’s Guide e Against Intellectual Property. + parag2: Fez mestrado em Direito Comercial Internacional no King’s College London, doutorado no Paul M. Hebert Law Center da Universidade Estadual da Louisiana, e diplomas de BSEE e MSEE. Seus websites são stephankinsella.com e kinsellalaw.com + michael: + title: Conselheiro de Ética + parag1: Michael Huemer é Professor de Filosofia e Ética na Universidade do Colorado, onde leciona desde 1998. É o autor de três obras acadêmicas (incluindo Ethical Intuitionism), editor de uma antologia, e mais de 50 artigos acadêmicos sobre epistemologia, ética, filosofia política e metafísica. + parag2: Os artigos de Huemer foram publicados na Philosophical Review, Mind, Journal of Philosophy, Ethics e outros periódicos. Seus textos são lidos em salas de aula em todos os EUA. Formou-se na Universidade da Califórnia em Berkeley e obteve seu Ph.D. na Universidade Rutgers. +social: + tweets: Tweets de @LBRYio (em inglês) +download: + main: + title: LBRY para %os% \ No newline at end of file diff --git a/lib/i18n.class.php b/lib/i18n.class.php index d52eaa9b..4ce0f5c1 100644 --- a/lib/i18n.class.php +++ b/lib/i18n.class.php @@ -4,8 +4,8 @@ * i18n dummy we'll be happy to have later */ function __($msg, $args = []) -{ - return strtr($msg, $args); +{ + return strtr(i18n::translate($msg), $args); } /** @@ -15,9 +15,43 @@ function __($msg, $args = []) */ class i18n { - public static function register() /*needed to trigger class include, presumably setup would happen here*/ + protected static + $language = null, + $translations = [], + $country = null; + + public static function register($culture = null) /*needed to trigger class include, presumably setup would happen here*/ { - setlocale(LC_MONETARY, 'en_US.UTF-8'); + if ($culture === null) + { + $urlTokens = $_SERVER['HTTP_HOST'] ? explode('.', $_SERVER['HTTP_HOST']) : []; + $code = $urlTokens ? reset($urlTokens) : 'en'; + switch($code) + { + case 'pt': + $culture = 'pt_PT'; break; + case 'en': + case 'www': + default: + $culture = 'en_US'; + } + } + + list($language, $country) = explode('_', $culture); + static::$language = $language; + static::$country = $country; + + setlocale(LC_MONETARY, $culture . '.UTF-8'); + } + + public static function getLanguage() + { + return static::$language; + } + + public static function getCountry() + { + return static::$country; } public static function formatCurrency($amount, $currency = 'USD') @@ -29,4 +63,31 @@ class i18n { return '' . number_format($amount, 1) . ' LBC'; } + + public static function translate($token, $language = null) + { + $language = $language === null ? static::$language : $language; + if (!isset(static::$translations[$language])) + { + $path = ROOT_DIR . '/data/i18n/' . $language . '.yaml'; + static::$translations[$language] = file_exists($path) ? Spyc::YAMLLoadString(file_get_contents($path)) : []; + } + $scope = static::$translations[$language]; + foreach(explode('.', $token) as $level) + { + if (isset($scope[$level])) + { + $scope = $scope[$level]; + } + else + { + $scope = []; + } + } + if (!$scope && $language != 'en') + { + return static::translate($token, 'en'); + } + return $scope ?: $token; + } } diff --git a/view/View.class.php b/view/View.class.php index 422800db..8d4efbcf 100644 --- a/view/View.class.php +++ b/view/View.class.php @@ -57,7 +57,8 @@ class View throw $e; } - return ob_get_clean(); + + return static::interpolateTokens(ob_get_clean()); } public static function markdownToHtml($path) @@ -123,4 +124,11 @@ class View $css = $scssCompiler->compile(file_get_contents(ROOT_DIR.'/web/scss/all.scss')); file_put_contents(ROOT_DIR.'/web/css/all.css', $css); } + + protected static function interpolateTokens($html) + { + return preg_replace_callback('/{{[\w\.]+}}/is', function($m) { + return i18n::translate(trim($m[0], '}{')); + }, $html); + } } \ No newline at end of file diff --git a/view/template/content/_postAuthor.php b/view/template/content/_postAuthor.php index 060433d9..8c710a8e 100644 --- a/view/template/content/_postAuthor.php +++ b/view/template/content/_postAuthor.php @@ -5,7 +5,7 @@ <?php echo __('Photo of %name%', ['%name%' => $authorName]) ?>
-
Author
+
{{news.author}}

diff --git a/view/template/content/_postNav.php b/view/template/content/_postNav.php index eca06397..5def6c0b 100644 --- a/view/template/content/_postNav.php +++ b/view/template/content/_postNav.php @@ -2,7 +2,7 @@