Skip to content

Instantly share code, notes, and snippets.

View JPustkuchen's full-sized avatar

Julian Pustkuchen JPustkuchen

View GitHub Profile
@Erikdekamps
Erikdekamps / add_translations.install
Last active June 6, 2023 07:40
Drupal 8 - Programmatically translate strings via hook_update_N()
/**
* Helper function for adding translations.
*
* @param array $strings
* The array with strings and their translations.
*/
function _my_module_add_translations(array $strings) {
// Get locale storage service.
$storage = \Drupal::service('locale.storage');
@JPustkuchen
JPustkuchen / d8-remove-wrong-equal-translations-l10n.md
Last active March 7, 2021 10:23
Drupal 8 CMS: Delete equal customized translation (source language string = target language string)

Drupal 8 CMS: Delete equal customized translation (source language string = target language string)

If you should encounter the problem that some translations are wrongly translated with the equal source language string (for example in our case there were German translations for "Author" translated with "Author" or "Published" with "Published"), you may use the following snippet to list them.

SELECT s.lid,s.source, t.translation FROM `locales_source` s
INNER JOIN locales_target t
WHERE s.lid=t.lid AND CONVERT(s.source USING utf8) = CONVERT(t.translation USING utf8) 
AND t.customized=1

To finally delete them, you may use something like this, but make a backup before and know what you're doing!

@JPustkuchen
JPustkuchen / scrollToMiddle.js
Created August 14, 2019 12:42
jQuery: Scroll element to the middle of the viewport
(function($) {
/**
* jQuery function to scroll the viewport middle to the element.
*/
$.fn.scrollToMiddle = function(options) {
var settings = $.extend({
duration: 1000
}, options );
return this.each(function() {
@leodutra
leodutra / -setup-windows-wsl-devenv.md
Last active May 13, 2024 18:30
Install and Setup Windows Subsystem 2 for Linux, Hyper, ZSH + Oh My Zsh + Powerlevel9k + plugins, FNM + VSCode (+ext) and Nerd Font

Setup Windows Subsystem 2 for Linux

Windows Subsystem 2 for Linux, Hyper, ZSH + Oh My Zsh + Powerlevel9k + plugins, FNM + VSCode (+ext) and Nerd Font

To setup native Linux, see this gist

Preview

Requirements

@plinionaves
plinionaves / vue-folder-structure.md
Last active May 17, 2024 09:53
Vue Project Folder Structure

Style Guide

This file describes de required Style Guide used by Basicamente to keep the Best Practices on develop new features or improve/change existents one.

Project folder structure

Always follow the folder structure below:

src/